Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
e154953
feat(deepagents, code): lean system prompt by default, restorable
nick-hollon-lc Jul 20, 2026
ce23402
refactor(deepagents, code): make _builtin_middleware_prompts private
nick-hollon-lc Jul 20, 2026
8d71dde
fix(deepagents, quickjs): keep skills/memory prompts on the lean default
nick-hollon-lc Jul 20, 2026
404d8f0
fix(deepagents): keep filesystem host-path routing when prose is supp…
nick-hollon-lc Jul 20, 2026
3ac886f
refactor(deepagents, code): public trim_duplicate_tool_prompts flag
nick-hollon-lc Jul 20, 2026
a08b327
refactor(deepagents, code): trim duplicate tool prose unconditionally
nick-hollon-lc Jul 21, 2026
36a22cd
refactor(deepagents): move essential trimmed guidance into tool descr…
nick-hollon-lc Jul 21, 2026
40880b3
fix(deepagents): correct offloaded-result grep guidance for artifacts…
nick-hollon-lc Jul 21, 2026
688d82c
refactor(deepagents): trim tool prose via lean middleware defaults
nick-hollon-lc Jul 21, 2026
cb90572
refactor(deepagents): delete the preserved built-in tool-prompt const…
nick-hollon-lc Jul 21, 2026
fb9c3d1
refactor(deepagents): disable default summarization prompt
nick-hollon-lc Jul 21, 2026
5b50172
refactor(deepagents): delete preserved summarization prompt
nick-hollon-lc Jul 21, 2026
1ab4c4a
test(code): refresh system prompt snapshot
nick-hollon-lc Jul 21, 2026
c9dbda2
chore(quickjs): sync lockfile with deepagents metadata
nick-hollon-lc Jul 21, 2026
4d825bb
fix(deepagents): address prompt middleware review feedback
nick-hollon-lc Jul 22, 2026
5d222b1
Merge remote-tracking branch 'origin/main' into nh/remove-base-system…
nick-hollon-lc Jul 22, 2026
c3c0ad0
Merge remote-tracking branch 'origin/main' into nh/remove-base-system…
nick-hollon-lc Jul 22, 2026
90ab0c5
test(sdk): rename base prompt test names
nick-hollon-lc Jul 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions libs/code/deepagents_code/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -2352,6 +2352,9 @@ def _subagent_cli_middleware(
agent = create_deep_agent(
model=model,
system_prompt=resolved_system_prompt,
# The SDK trims the built-in tool-usage guidance prose by default; the
# CLI keeps it to preserve its shipped behavior.
trim_duplicate_tool_prompts=False,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should leave this configurable. who would ever want this to be False? IMO we change the prompts in 0.7.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok what if someone really wants it back?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed for now

tools=tools,
backend=composite_backend,
middleware=agent_middleware,
Expand Down
2 changes: 2 additions & 0 deletions libs/deepagents/deepagents/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from deepagents._version import __version__
from deepagents.graph import (
DEFAULT_AGENT_PROMPT,
DeepAgentState,
SystemPromptConfig,
create_deep_agent,
Expand All @@ -27,6 +28,7 @@
)

__all__ = [
"DEFAULT_AGENT_PROMPT",
"AsyncSubAgent",
"AsyncSubAgentMiddleware",
"CompiledSubAgent",
Expand Down
82 changes: 70 additions & 12 deletions libs/deepagents/deepagents/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -117,16 +117,29 @@ 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 = ""

Copy link
Copy Markdown
Contributor

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?

"""Default base system prompt for every deep agent (empty by default).

The final system prompt sent to the model is assembled, in order, from:

1. `prefix` — caller text placed before the base (the `system_prompt=`
argument, or its `prefix` key). Always first, so caller instructions
take precedence.
2. `base` — this constant by default; replaced by the `system_prompt`
2. `base` — this constant by default (empty); replaced by the `system_prompt`
config's `base` key, or (when that key is absent) by
`HarnessProfile.base_system_prompt`. Setting `base` to `None` drops it.
Pass [`DEFAULT_AGENT_PROMPT`][deepagents.DEFAULT_AGENT_PROMPT] as the `base`
to restore the built-in authored prompt.
3. `suffix` — caller text placed after the base (the `system_prompt`
config's `suffix` key).
4. `HarnessProfile.system_prompt_suffix` — model-tuning guidance appended
Expand Down Expand Up @@ -378,6 +391,7 @@ def create_deep_agent( # noqa: C901, PLR0912, PLR0915 # Complex graph assembly
tools: Sequence[BaseTool | Callable | dict[str, Any]] | None = None,
*,
system_prompt: str | SystemMessage | SystemPromptConfig | None = None,
trim_duplicate_tool_prompts: bool = True,
middleware: Sequence[AgentMiddleware[StateT_co, ContextT]] = (),
subagents: Sequence[SubAgent | CompiledSubAgent | AsyncSubAgent] | None = None,
skills: list[str] | None = None,
Expand Down Expand Up @@ -449,22 +463,38 @@ def create_deep_agent( # noqa: C901, PLR0912, PLR0915 # Complex graph assembly
system_prompt: Custom system instructions.

A `str` or `SystemMessage` is placed at the front of the system
prompt, before the SDK's default base prompt and any model-tuning
suffix from a registered `HarnessProfile` (`system_prompt=None`
uses the default base on its own).
prompt, before the base prompt (empty by default) and any
model-tuning suffix from a registered `HarnessProfile`.

For more control, pass a
[`SystemPromptConfig`][deepagents.SystemPromptConfig] with any of:

- `prefix`: text before the base (same as passing a bare string).
- `base`: replace the built-in base prompt; omit the key to keep
it, or set it to `None` to drop the base entirely.
- `base`: replace the base prompt; omit the key to keep the default

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we intend to drop the system_prompt configurability that was added earlier in the 0.7 alpha period. I appreciate keeping things consistent but this will just add merge conflicts when we revert.

(empty), or set it to `None` to drop the base entirely. Pass
[`DEFAULT_AGENT_PROMPT`][deepagents.DEFAULT_AGENT_PROMPT] to
restore the built-in authored prompt.
- `suffix`: text after the base (before any profile suffix).

The assembly order is `prefix` -> `base` -> `suffix` ->
profile suffix, joined by blank lines. Any part may be a
`SystemMessage` to preserve `cache_control` markers; the result is
then a `SystemMessage` whose content blocks are concatenated.
trim_duplicate_tool_prompts: Whether to drop the built-in tool-usage
guidance prose that largely duplicates the tools' own descriptions.

`True` (default): the todo, filesystem, and subagent middleware are
built without their usage-guidance prose, on every stack (main agent,
subagents, and the general-purpose subagent). The tools and their own
schema descriptions are unaffected, so the model still knows how to
call them; only the redundant prose is trimmed. Set this to `False`
to keep the full built-in guidance.

This is deliberately narrow. It only trims prose that repeats the
tool schemas. It never touches content that the schemas do not carry:
the skills index and memory content (emitted whenever `skills=` /
`memory=` are set) and the filesystem host-path routing section
always remain, regardless of this flag.
middleware: Additional middleware to apply after the base stack
but before the tail middleware. The full ordering is:

Expand Down Expand Up @@ -734,6 +764,30 @@ class MyState(DeepAgentState):

backend = backend if backend is not None else StateBackend()

# Trim the built-in tool-usage guidance prose that duplicates the tool
# schemas. When `trim_duplicate_tool_prompts` (the default), todo /
# filesystem / subagent / async-subagent are constructed with that prose
# dropped, on every stack below (main agent, subagents, general-purpose
# subagent). The trim value depends on how the middleware treats
# `system_prompt`:
# - `TodoListMiddleware` always appends, so `""` trims; omitting the kwarg
# (empty dict) keeps its built-in prose.
# - `FilesystemMiddleware` builds its prose when `system_prompt is None`,
# so it is passed explicitly at each call site (`""` to trim, `None` to
# keep). Its host-path routing section is preserved either way (see
# `_filter_unsupported_tools_and_apply_prompt`).
# - subagent / async-subagent treat `None` as "no fragment", so `None`
# trims; omitting the kwarg keeps it. 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 intentionally 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 explicitly passes
# `skills=` / `memory=`. Trimming them would silently disable an opted-into
# feature, so they always emit their built-in fragment.
_empty_prompt_kwargs: dict[str, str] = {"system_prompt": ""} if trim_duplicate_tool_prompts else {}
_none_prompt_kwargs: dict[str, None] = {"system_prompt": None} if trim_duplicate_tool_prompts else {}

# 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
Expand Down Expand Up @@ -761,11 +815,12 @@ class MyState(DeepAgentState):

# Build middleware: base stack + skills (if specified) + user's middleware
subagent_middleware: list[AgentMiddleware[Any, Any, Any]] = [
TodoListMiddleware(),
TodoListMiddleware(**_empty_prompt_kwargs),
FilesystemMiddleware(
backend=backend,
custom_tool_descriptions=_subagent_profile.tool_description_overrides,
_permissions=subagent_permissions,
system_prompt="" if trim_duplicate_tool_prompts else None,
),
create_summarization_middleware(subagent_model, backend),
PatchToolCallsMiddleware(),
Expand Down Expand Up @@ -847,11 +902,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(**_empty_prompt_kwargs),
FilesystemMiddleware(
backend=backend,
custom_tool_descriptions=_profile.tool_description_overrides,
_permissions=permissions,
system_prompt="" if trim_duplicate_tool_prompts else None,
),
create_summarization_middleware(model, backend),
PatchToolCallsMiddleware(),
Expand Down Expand Up @@ -913,7 +969,7 @@ class MyState(DeepAgentState):

# Build main agent middleware stack
deepagent_middleware: list[AgentMiddleware[Any, Any, Any]] = [
TodoListMiddleware(),
TodoListMiddleware(**_empty_prompt_kwargs),
]
if skills is not None:
deepagent_middleware.append(SkillsMiddleware(backend=backend, sources=skills))
Expand All @@ -922,6 +978,7 @@ class MyState(DeepAgentState):
backend=backend,
custom_tool_descriptions=_profile.tool_description_overrides,
_permissions=permissions,
system_prompt="" if trim_duplicate_tool_prompts else None,
)
)
sub_agent_middleware: SubAgentMiddleware | None = None
Expand All @@ -936,6 +993,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,
**_none_prompt_kwargs,
)
deepagent_middleware.append(sub_agent_middleware)
deepagent_middleware.extend(
Expand All @@ -948,7 +1006,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, **_none_prompt_kwargs))

# 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.
Expand Down
13 changes: 11 additions & 2 deletions libs/deepagents/deepagents/middleware/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -2792,9 +2792,18 @@ def _filter_unsupported_tools_and_apply_prompt(self, request: ModelRequest[Conte
if described_tools is not visible_tools:
request = request.override(tools=described_tools)

# Use custom system prompt if provided, otherwise generate dynamically
# A `system_prompt` override (including `""` suppression) replaces only the
# usage-guidance prose. The host-path routing section is essential
# per-backend config (virtual->host path mapping for the `execute` shell),
# not prose, so it is still appended when the execute tool is active — even
# when the prose is overridden or suppressed.
if self._custom_system_prompt is not None:
system_prompt = self._custom_system_prompt
prompt_parts = [self._custom_system_prompt] if self._custom_system_prompt else []
if execution_active:
route_prompt = _route_host_path_prompt(cast("BackendProtocol", backend))
if route_prompt:
prompt_parts.append(route_prompt)
system_prompt = "\n\n".join(prompt_parts).strip()
else:
# Build dynamic system prompt reflecting only the tools that survived filtering
visible_fs = {n for n in (tool_names - unsupported) if n is not None}
Expand Down
Loading