Repository navigation
Add capabilities to Common AI AgentOperator - #73984
Merged
Merged
Conversation
kaxil
requested review from
Lee-W,
amoghrajesh and
vatsrahul1001
and removed request for
Lee-W,
ashb and
gopidesupavan
September 30, 2026 19:53
Lee-W
reviewed
Oct 1, 2026
vatsrahul1001
approved these changes
Oct 1, 2026
vatsrahul1001
left a comment
Contributor
There was a problem hiding this comment.
test conflicts needs to be resolved
AgentOperator and @task.agent take a capabilities= list of pydantic-ai capabilities, kept out of the serialized Dag and templated like toolsets=. capabilities inside agent_params still works; passing both fails the task. A CodeMode capability is now refused with durable=True and turns off per-tool approval, matching code_mode=True. The guardrails docs page becomes a capabilities page.
kaxil
force-pushed
the
commonai-capabilities-kwarg
branch
from
October 1, 2026 08:45
8dfc118 to
0ec4457
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AgentOperatorand@task.agentnow take pydantic-ai capabilities directly:Capabilities are pydantic-ai's unit for adding behavior to an agent (tools, instructions, model settings, and hooks around each model request or tool call), and the way guardrail packages such as
pydantic-ai-shieldsplug in. Until now the only route wasagent_params={"capabilities": [...]}.agent_paramsis a template field, so every capability ended up in the serialized Dag as its repr, and for a capability holding a function that repr includes a memory address. The same Dag, run once each way:agent_params={"capabilities": [...]}capabilities=[...]capabilities=is not a template field, liketoolsets=, so nothing about the capability reaches the serialized Dag; the worker builds it from the Dag file. AToolsetcapability holding one of this provider's toolsets still has its connection IDs templated per task instance, the same waytoolsets=does.Design rationale
capabilitiesinsideagent_paramskeeps working, but not together with the new argument. pydantic-ai wraps capability hooks in list order, first outermost, so merging two lists would pick an order the Dag author never wrote. Passing both fails the task with aValueError. The check runs when the agent is built rather than in__init__, becauseagent_paramscan still be an unrendered template or anXComArgat construction time.Code mode is now recognized however it is passed. The
durable=Truecheck and the per-tool approval check only looked atcode_mode=True, so aCodeMode()capability got past both:durable=Trueaccepted it, and approval stayed on alongside code mode. Both now findCodeModeat the top level, inside aCombinedCapability, or inside a wrapper such asPrefixTools.code_mode=Trueplus aCodeMode()capability would add two, so that combination is refused too. The lookup never importspydantic-ai-harness, so an agent that does not use code mode is unaffected when the harness is installed without itscode-modeextra.Agent-only for now.
LLMOperatorand its siblings still passagent_paramsstraight toAgent(...), so capabilities there keep working the old way.Docs
The "Guardrails" page becomes "Capabilities and guardrails" (
guardrails.htmlredirects), with a table of what a retry replays underdurable=Truefor each kind of capability:Gotchas
AgentOperator.partial(...).expand(...), or a mapped@task.agent) stores everypartialargument, so therecapabilitiesis serialized as a repr.CodeModebuilt by a capability function when the run starts cannot be seen before the run, so thedurable=Truecheck does not catch it.