Repository navigation
feat(sdk,code,quickjs): lean system prompt by default, restorable #4859
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 7 commits
e154953
ce23402
8d71dde
404d8f0
3ac886f
a08b327
36a22cd
40880b3
688d82c
cb90572
fb9c3d1
5b50172
1ab4c4a
c9dbda2
4d825bb
5d222b1
c3c0ad0
90ab0c5
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 |
|---|---|---|
|
|
@@ -74,7 +74,7 @@ class DeepAgentState(AgentState): | |
| messages: Required[Annotated[list[AnyMessage], DeltaChannel(_messages_delta_reducer, snapshot_frequency=50)]] # ty: ignore[invalid-argument-type] | ||
|
|
||
|
|
||
| BASE_AGENT_PROMPT = """You are a deep agent, an AI assistant that helps users accomplish tasks using tools. You respond with text and tool calls. The user can see your responses and tool outputs in real time. | ||
| DEFAULT_AGENT_PROMPT = """You are a deep agent, an AI assistant that helps users accomplish tasks using tools. You respond with text and tool calls. The user can see your responses and tool outputs in real time. | ||
|
|
||
| ## Core Behavior | ||
|
|
||
|
|
@@ -117,7 +117,18 @@ class DeepAgentState(AgentState): | |
| ## Progress Updates | ||
|
|
||
| For longer tasks, provide brief progress updates at reasonable intervals — a concise sentence recapping what you've done and what's next.""" # noqa: E501 | ||
| """Default base system prompt for every deep agent. | ||
| """Authored base prompt (persona + task guidance), available for opt-in. | ||
|
|
||
| Not injected by default. `BASE_AGENT_PROMPT` — the base the prompt assembler | ||
| uses — is empty, so a deep agent ships with no authored base prompt. Callers who | ||
| want this built-in persona and task guidance back pass it explicitly, e.g. | ||
| `create_deep_agent(system_prompt={"base": DEFAULT_AGENT_PROMPT})`, or set it as a | ||
| `HarnessProfile.base_system_prompt`. | ||
| """ | ||
|
|
||
|
|
||
| BASE_AGENT_PROMPT = "" | ||
| """Default base system prompt for every deep agent (empty by default). | ||
|
|
||
| The final system prompt sent to the model is assembled, in order, from: | ||
|
|
||
|
|
@@ -734,6 +745,19 @@ class MyState(DeepAgentState): | |
|
|
||
| backend = backend if backend is not None else StateBackend() | ||
|
|
||
| # The built-in tool-usage guidance prose duplicates the tools' own schema | ||
| # descriptions, so it is trimmed on every stack below (main agent, subagents, | ||
| # general-purpose subagent) via each middleware's `system_prompt`: | ||
| # - `TodoListMiddleware` and `FilesystemMiddleware` always append, so `""` | ||
| # trims their prose. Filesystem's host-path routing section is preserved | ||
| # regardless (see `_filter_unsupported_tools_and_apply_prompt`). | ||
| # - subagent / async-subagent treat `None` as "no fragment", so `None` | ||
| # trims. The available-agent list still reaches the model through the | ||
| # `task` tool / async tools, so only the duplicate usage prose is dropped. | ||
| # Skills and Memory are never trimmed: their fragment is the only channel that | ||
| # surfaces the loaded skill index / memory content (no tool carries it), and | ||
| # both are built only when the caller passes `skills=` / `memory=`. | ||
|
|
||
| # Process caller-supplied subagents first so the decision of whether to | ||
| # auto-add the default general-purpose subagent can factor in an explicit | ||
| # override, and so its middleware stack (including any factory-based | ||
|
|
@@ -761,11 +785,12 @@ class MyState(DeepAgentState): | |
|
|
||
| # Build middleware: base stack + skills (if specified) + user's middleware | ||
| subagent_middleware: list[AgentMiddleware[Any, Any, Any]] = [ | ||
| TodoListMiddleware(), | ||
| TodoListMiddleware(system_prompt=""), | ||
| FilesystemMiddleware( | ||
| backend=backend, | ||
| custom_tool_descriptions=_subagent_profile.tool_description_overrides, | ||
| _permissions=subagent_permissions, | ||
| system_prompt="", | ||
| ), | ||
| create_summarization_middleware(subagent_model, backend), | ||
| PatchToolCallsMiddleware(), | ||
|
|
@@ -847,11 +872,12 @@ class MyState(DeepAgentState): | |
| gp_profile = _profile.general_purpose_subagent or GeneralPurposeSubagentProfile() | ||
| if gp_profile.enabled is not False and not any(spec["name"] == GENERAL_PURPOSE_SUBAGENT["name"] for spec in inline_subagents): | ||
| gp_middleware: list[AgentMiddleware[Any, Any, Any]] = [ | ||
| TodoListMiddleware(), | ||
| TodoListMiddleware(system_prompt=""), | ||
| FilesystemMiddleware( | ||
| backend=backend, | ||
| custom_tool_descriptions=_profile.tool_description_overrides, | ||
| _permissions=permissions, | ||
| system_prompt="", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how do we feel about all the dead code here?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we haven't already, we need to audit the content we're losing from system prompts (i.e., is not duplicated in tool descriptions) and convince ourselves we don't want them. some things we lose:
|
||
| ), | ||
| create_summarization_middleware(model, backend), | ||
| PatchToolCallsMiddleware(), | ||
|
|
@@ -913,7 +939,7 @@ class MyState(DeepAgentState): | |
|
|
||
| # Build main agent middleware stack | ||
| deepagent_middleware: list[AgentMiddleware[Any, Any, Any]] = [ | ||
| TodoListMiddleware(), | ||
| TodoListMiddleware(system_prompt=""), | ||
| ] | ||
| if skills is not None: | ||
| deepagent_middleware.append(SkillsMiddleware(backend=backend, sources=skills)) | ||
|
|
@@ -922,6 +948,7 @@ class MyState(DeepAgentState): | |
| backend=backend, | ||
| custom_tool_descriptions=_profile.tool_description_overrides, | ||
| _permissions=permissions, | ||
| system_prompt="", | ||
| ) | ||
| ) | ||
| sub_agent_middleware: SubAgentMiddleware | None = None | ||
|
|
@@ -936,6 +963,7 @@ class MyState(DeepAgentState): | |
| # template. Stale keys silently no-op if the tool is renamed. | ||
| task_description=_profile.tool_description_overrides.get("task"), | ||
| state_schema=state_schema, | ||
| system_prompt=None, | ||
| ) | ||
| deepagent_middleware.append(sub_agent_middleware) | ||
| deepagent_middleware.extend( | ||
|
|
@@ -948,7 +976,7 @@ class MyState(DeepAgentState): | |
| if async_subagents: | ||
| # Async here means that we run these subagents in a non-blocking manner. | ||
| # Currently this supports agents deployed via LangSmith deployments. | ||
| deepagent_middleware.append(AsyncSubAgentMiddleware(async_subagents=async_subagents)) | ||
| deepagent_middleware.append(AsyncSubAgentMiddleware(async_subagents=async_subagents, system_prompt=None)) | ||
|
|
||
| # Names of the core stack, captured before the tail is appended so new user | ||
| # middleware can splice in ahead of the profile/prompt-caching/memory tail. | ||
|
|
||
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.
what's the point of this?