Repository navigation
Add a vendor-neutral managed-agent hook contract to Common AI - #73532
Merged
Merged
Conversation
kaxil
force-pushed
the
managed-agent-hook-contract
branch
from
September 22, 2026 10:14
959f796 to
f71663e
Compare
kaxil
force-pushed
the
managed-agent-hook-contract
branch
4 times, most recently
from
September 30, 2026 11:28
b1d6ab1 to
131df1c
Compare
kaxil
marked this pull request as ready for review
September 30, 2026 11:36
kaxil
requested review from
Lee-W,
amoghrajesh,
ashb,
bugraoz93,
choo121600,
ephraimbuddy,
gopidesupavan,
jason810496,
jedcunningham,
jscheffl,
o-nikolas,
potiuk,
shahar1 and
vatsrahul1001
as code owners
September 30, 2026 11:36
kaxil
force-pushed
the
managed-agent-hook-contract
branch
4 times, most recently
from
September 30, 2026 13:15
cb18c21 to
d856d3c
Compare
Lee-W
approved these changes
Oct 1, 2026
Lee-W
left a comment
Member
There was a problem hiding this comment.
a few naming nits. nothing blockign thanks!
get_agent_capabilities on the contract, and on the Bedrock hook _get_client, _describe_call and _extract_text, with the test helper named for what it builds. Walrus the reserved-options check and inline the raw envelope.
kaxil
force-pushed
the
managed-agent-hook-contract
branch
from
October 1, 2026 09:38
4d52588 to
7076f5d
Compare
vatsrahul1001
approved these changes
Oct 1, 2026
1 task done
1 task done
28 of 93 tasks
1 task done
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.
Airflow has five ways to invoke a vendor-hosted agent (Bedrock AgentCore, Vertex AI Agent Engine, Azure AI Foundry, Snowflake Cortex, Anthropic Managed Agents) and none of them share an argument name, a result shape or an error class.
BaseManagedAgentToolsetfrom #71946 was supposed to fix that. A month later it has zero implementations. The reason is structural: adopting it means subclassing a pydantic-ai toolset from inside a provider that still supports Airflow 2, which nobody can do.So this moves the common surface to where
DbApiHookput it: the hook.airflow.providers.common.ai.managed_agentsdefinesBaseManagedAgentHook, a mixin a vendor hook adopts next to its own base. The agent is an argument, like a statement is toDbApiHook.run. Three methods (resolve_agent,agent_capabilities,invoke_agent), typed request/response dataclasses, no pydantic-ai import.BedrockAgentCoreHookadopts it for AgentCore runtimes andAgentEngineHookfor Agent Engine deployments, the wayBigQueryHookis aDbApiHook: the capability lives on the existing hook, with no second hook or module to find. On top, written once:ManagedAgentToolset(any client of the contract becomes one tool for a calling model) andFailoverManagedAgentClient(clients composed across clouds).Design rationale
Vendors take common.ai as an optional extra, exactly as they take common.messaging today. common.ai needs Airflow 3.0; amazon and google still floor 2.11. There is already a pattern in the repo for a 3.x-only common base adopted by 2.x providers:
BaseMessageQueueProvider. An extra inpyproject.toml,pytest.importorskipin the tests, and a guarded import of the contract base. Because the capability sits onBedrockAgentCoreHookandAgentEngineHookthemselves, those modules have to import without common.ai installed, so the guard follows theResumableJobMixinstub inglue.pyrather than raising at import: without the extra the hook works as before andhook.agent(...)raisesAirflowOptionalProviderFeatureExceptionnaming what to install. Plainamazoninstalls are untouched; pydantic-ai only arrives withamazon[common.ai].Type the intersection, pass the rest through. Identity, prompt or messages, an optional session, a timeout, a text answer: those mean the same thing everywhere and are typed. The rest rides in
vendor_optionsin andrawout. Each hook rejects options that would point the call somewhere else (another ARN, account, engine). The model seestext. Python callers getraw.Why
ManagedAgentRejectedinstead ofModelRetry. The contract has to stay free of pydantic-ai or the guarded import stops being cheap. The toolset translates at the boundary. As it turns out neither adopted platform has a rephrase-class error anyway: AgentCore returns a container's complaints inside a 200, and Agent Engine'sINVALID_ARGUMENTis an author mistake (wrong input key), not something a model can fix by rewording. Both hooks raise terminal errors or let transient ones through.Failover over clients, not toolsets. The removed
FailoverManagedAgentToolsettook toolsets as members but only ever calledinvokeon them, so a member'stool_name,descriptionandmax_retriesdid nothing. It also resolved every member's identity before the call, so a standby with a bad connection failed calls the primary would have answered. The new group takes clients, resolves identity only for logs and metric tags, logs which member answered, and refuses any request carrying asession_id(a failover starts a fresh conversation on the standby). A bound agent applies the same rule for a single hook whose capabilities do not include sessions.replayablenow does something. #71946 declared it; nothing read it;durable=Truereplayed managed-agent calls from cache regardless.CachingToolsetnow runs the tool instead of replaying when the wrapped toolset saysreplayable=False, and it looks throughprefixed,filteredandCombinedToolset, which do not carry the attribute.Migration path
common.ai is 0.x and the old base had no subclasses in tree. Still, for anyone who tried it:
FailoverManagedAgentToolsetis gone. UseManagedAgentToolset(FailoverManagedAgentClient([...]), ...).BaseManagedAgentToolset.agent_refreturns aManagedAgentRefrather than adict[str, str].managed_agent.servedlosesroleandposition, gainstool.managed_agent.failoverlosestool.servedcounts answers,failovercounts transitions; read them next to each other. Which member answered is in the task log.The new amazon and google extras carry the
# use next versionmarker for the release manager.Gotchas
timeoutbecomes connect/read timeout without a new session per tool call. Retries off unless the connection or caller set them. The connection'sconfig_kwargsapply as for any AWS hook. Session ids are checked against AgentCore's 33 to 256 character bound before the call.text_key(which response field holds the answer) andmax_response_bytestravel invendor_options, because an AWS hook constructor takes no arguments of its own. Non-JSON, malformed or oversize bodies are terminal errors that name the agent and connection.session_idis refused rather than silently sent as a fresh call.class_methodandinput_keyare per-requestvendor_optionstoo, defaulting toqueryandinput. Query jobs stay onRunQueryJobOperator, which can defer.Supersedes the toolset-only design of #71946.
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.