Skip to content

fix(a2a-adapter): add follow_redirects=True to httpx AsyncClient calls#868

Open
bleib1dj wants to merge 7 commits into
fetchai:mainfrom
bleib1dj:v2_upgrade
Open

fix(a2a-adapter): add follow_redirects=True to httpx AsyncClient calls#868
bleib1dj wants to merge 7 commits into
fetchai:mainfrom
bleib1dj:v2_upgrade

Conversation

@bleib1dj

Copy link
Copy Markdown
Contributor

Summary

httpx.AsyncClient defaults follow_redirects to False, 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 - 4 httpx.AsyncClient instantiations now include follow_redirects=True:
    • _send_to_a2a_agent (message sending)
    • _discover_and_health_check_agents (agent card fetching)
    • route_to_llm (LLM API routing)
    • Agent card well-known endpoint fetching

How tested

  • Code review of all httpx.AsyncClient instantiations in the adapter
  • Confirmed the change is additive - no behavioral change for endpoints that do not redirect

Risks / breaking changes

None. Adding follow_redirects=True makes httpx behave like requests and aiohttp do by default.

bleib1dj added 7 commits June 23, 2025 16:58
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.
Comment on lines +543 to 553
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(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant