fix(a2a-adapter): add follow_redirects=True to httpx AsyncClient calls - #868
fix(a2a-adapter): add follow_redirects=True to httpx AsyncClient calls#868bleib1dj wants to merge 7 commits into
Conversation
httpx.AsyncClient defaults follow_redirects to False, causing 308 Permanent Redirect responses from Agentverse and A2A endpoints to be returned as errors instead of followed. Affects agent discovery, health checks, message sending, and LLM routing.
| logger.info("successfully registered to Agentverse.") | ||
|
|
||
| # set agent as active | ||
| if agent_registration.active: | ||
| try: | ||
| logger.info("setting agent as active...") | ||
| _update_agent_status(True, identity) | ||
| logger.info("successfully set agent to active.") | ||
| except AgentverseRequestError as e: | ||
| logger.warning(f"failed to set agent as active. {str(e)}") | ||
| logger.info("setting agent as active...") | ||
| _update_agent_status(True, identity) | ||
| logger.info("successfully set agent to active.") | ||
|
|
||
| return True | ||
|
|
||
|
|
||
| def register_chat_agent( |
There was a problem hiding this comment.
Bug: The error handling in register_agent() and register_chat_agent() was changed, causing AgentverseRequestError to propagate instead of being silently handled. This is an undocumented breaking change.
Severity: HIGH
Suggested Fix
The breaking change should be explicitly documented in the pull request description and release notes to inform users of the new behavior. Alternatively, revert the change to maintain backward compatibility or introduce a new function for the new behavior. The change should not be bundled with an unrelated bug fix.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: python/uagents-core/uagents_core/utils/registration.py#L533-L553
Potential issue: The functions `register_agent()` and `register_chat_agent()` were
modified to no longer catch `AgentverseRequestError`. Previously, registration failures
were logged and the function returned `None`, allowing the calling application to
continue execution. With the new changes, if registration fails, the
`AgentverseRequestError` will propagate unhandled. This can crash any downstream
application that calls these functions without its own `try/except` block, as they may
not be prepared to handle this exception. This constitutes a breaking API change that
was not documented in the pull request description.
Did we get this right? 👍 / 👎 to inform future reviews.
Real-world repro context: hosted mailbox A2A agent (PropertyAI Advisor)Sharing an external A2A agent setup that hits this exact class of failure. Happy to help validate once this lands. Setup / workflow
Agent listing: mailbox-relay A2A agent property-ai-advisor / Property AI Advisor. What failsWhen chatting to the hosted A2A agent through Agentverse/ASI:One we see HTTP 308 Permanent Redirect failures on the client side. Root cause matches this PR: That lines up with:
Ask (same as this PR)Please set
Same class of fix is needed anywhere Agentverse/ASI:One calls A2A over httpx (companion: flockx-official/platform#11263). Why this matters beyond this agentMost external A2A setups hit this: JSON-RPC served at Extra constraint we hitURI was fixed at mailbox onboarding; we cannot re-evaluate or switch to a public endpoint without a new profile. So until redirect-following lands, mailbox chat stays broken even though the public Railway JSON-RPC endpoint is healthy. Thanks for the fix — landing this should unblock mailbox-relay A2A agents like this one. |
Summary
httpx.AsyncClientdefaultsfollow_redirectstoFalse, causing 308 Permanent Redirect responses from Agentverse and A2A endpoints to be returned as errors instead of being followed. This affects agent discovery, health checks, message sending, and LLM routing in the A2A outbound adapter.This is a companion fix to flockx-official/platform#11263, which addresses the same issue in the platform codebase.
Notable changes
a2a_outbound/adapter.py- 4httpx.AsyncClientinstantiations now includefollow_redirects=True:_send_to_a2a_agent(message sending)_discover_and_health_check_agents(agent card fetching)route_to_llm(LLM API routing)How tested
httpx.AsyncClientinstantiations in the adapterRisks / breaking changes
None. Adding
follow_redirects=Truemakes httpx behave likerequestsandaiohttpdo by default.