Skip to content

docs: clarify end_strategy values in agent spec#6140

Merged
hramezani merged 2 commits into
pydantic:mainfrom
VectorPeak:fix
Jun 30, 2026
Merged

docs: clarify end_strategy values in agent spec#6140
hramezani merged 2 commits into
pydantic:mainfrom
VectorPeak:fix

Conversation

@VectorPeak

@VectorPeak VectorPeak commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

This keeps agents and spec-driven readers from making decisions from stale docs and carrying an outdated end_strategy assumption into their context.

What Problem This Solves

docs/agent-spec.md documented end_strategy as accepting only 'early' or 'exhaustive'.

The actual EndStrategy type is Literal['early', 'graceful', 'exhaustive'], and AgentSpec.end_strategy defaults to 'graceful'. Leaving the agent spec docs behind the code can mislead readers and spec-driven agent/context configuration into treating the default strategy as unavailable.

Recommendation

This should be updated because agent-spec.md acts as the declarative contract readers use when configuring agents from specs. If it omits the current default, downstream examples, generated configs, or agent-context setup can incorrectly treat 'graceful' as invalid or unsupported, creating avoidable context/configuration confusion even though the runtime already supports it.

Change

  • Add 'graceful' to the end_strategy values listed in the AgentSpec field table.

Evidence

  • pydantic_ai_slim/pydantic_ai/_agent_graph.py defines EndStrategy = Literal['early', 'graceful', 'exhaustive'].
  • pydantic_ai_slim/pydantic_ai/agent/spec.py sets end_strategy: EndStrategy = 'graceful'.

Validation

  • rg -n "end_strategy|EndStrategy|graceful|exhaustive" docs/agent-spec.md pydantic_ai_slim/pydantic_ai/_agent_graph.py pydantic_ai_slim/pydantic_ai/agent/spec.py
  • git diff --check

uv run pre-commit run no-rst-syntax --files docs/agent-spec.md was attempted, but pre-commit is not installed in the current environment (program not found).

Checklist

  • Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
  • No breaking changes in accordance with the version policy.
  • PR title is fit for the release changelog.

Review in cubic

@github-actions github-actions Bot added size: S Small PR (≤100 weighted lines) docs Improvements or additions to documentation labels Jun 30, 2026
@VectorPeak
VectorPeak marked this pull request as ready for review June 30, 2026 01:40
@hramezani
hramezani merged commit abd3e6e into pydantic:main Jun 30, 2026
62 checks passed
@hramezani

Copy link
Copy Markdown
Collaborator

Thanks @VectorPeak

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation size: S Small PR (≤100 weighted lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants