-
Notifications
You must be signed in to change notification settings - Fork 2k
feat: add clean context and token budget for subagents #2337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -240,8 +240,6 @@ export interface ToolConfig { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export interface ModelConfig { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * The name or identifier of the model to be used (e.g., 'qwen3-coder-plus'). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * TODO: In the future, this needs to support 'auto' or some other string to support routing use cases. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| model?: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -258,8 +256,6 @@ export interface ModelConfig { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Configures the execution environment and constraints for the subagent. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * This interface defines parameters that control the subagent's runtime behavior, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * such as maximum execution time, to prevent infinite loops or excessive resource consumption. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * TODO: Consider adding max_tokens as a form of budgeting. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export interface RunConfig { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** The maximum execution time for the subagent in minutes. */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -269,4 +265,39 @@ export interface RunConfig { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * before the execution is terminated. Helps prevent infinite loops. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| max_turns?: number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * When true, the subagent starts with a clean context window, not inheriting | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * the main session's conversation history via getInitialChatHistory(). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Only environment context (working directory, date, OS) is provided. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * This prevents context bloat during long sessions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| useCleanContext?: boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Maximum number of tokens allowed for context injection. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * When exceeded, context is truncated to fit within this budget. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * If not specified, no token budget is enforced. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| maxContextTokens?: number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * When true, instructs the subagent to format its output using a structured | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * summary schema (findings, files changed, conclusion). This ensures only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * distilled summaries are injected back into the main context. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+272
to
+285
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * This prevents context bloat during long sessions. | |
| */ | |
| useCleanContext?: boolean; | |
| /** | |
| * Maximum number of tokens allowed for context injection. | |
| * When exceeded, context is truncated to fit within this budget. | |
| * If not specified, no token budget is enforced. | |
| */ | |
| maxContextTokens?: number; | |
| /** | |
| * When true, instructs the subagent to format its output using a structured | |
| * summary schema (findings, files changed, conclusion). This ensures only | |
| * distilled summaries are injected back into the main context. | |
| */ | |
| * This prevents context bloat during long sessions. | |
| * | |
| * Prefer using the snake_case `use_clean_context` key in YAML/frontmatter. | |
| * The camelCase `useCleanContext` field is kept for backwards compatibility. | |
| */ | |
| use_clean_context?: boolean; | |
| useCleanContext?: boolean; | |
| /** | |
| * Maximum number of tokens allowed for context injection. | |
| * When exceeded, context is truncated to fit within this budget. | |
| * If not specified, no token budget is enforced. | |
| * | |
| * Prefer using the snake_case `max_context_tokens` key in YAML/frontmatter. | |
| * The camelCase `maxContextTokens` field is kept for backwards compatibility. | |
| */ | |
| max_context_tokens?: number; | |
| maxContextTokens?: number; | |
| /** | |
| * When true, instructs the subagent to format its output using a structured | |
| * summary schema (findings, files changed, conclusion). This ensures only | |
| * distilled summaries are injected back into the main context. | |
| * | |
| * Prefer using the snake_case `use_structured_output` key in YAML/frontmatter. | |
| * The camelCase `useStructuredOutput` field is kept for backwards compatibility. | |
| */ | |
| use_structured_output?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The YAML examples document
runConfigkeys in camelCase (e.g.useCleanContext,maxContextTokens,useStructuredOutput) but the rest ofRunConfig(and prior docs) use snake_case (e.g.max_turns,max_time_minutes). If the implementation expects one naming style, this doc will lead to misconfiguration. Align the examples with the actual supported key names (or explicitly document that both styles are accepted).