Skip to content

Add a2a_trading_agents: runnable project replacing the A2A notebook - #77

Merged
PatriciaArnedo merged 3 commits into
mainfrom
a2a-trading-agents
Aug 5, 2026
Merged

Add a2a_trading_agents: runnable project replacing the A2A notebook#77
PatriciaArnedo merged 3 commits into
mainfrom
a2a-trading-agents

Conversation

@PatriciaArnedo

@PatriciaArnedo PatriciaArnedo commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Replaces the A2A multi-agent notebook with a real project, so the companion docs guide can drop its Colab links. Paired with a docs PR in Arize-ai/docs.

The notebook built its own file tree at runtime by writing triple-quoted strings to disk (mcp_tools/bear_tools.py and friends). Those are now actual modules that can be read, imported, and run.

What it is

Two agents on different frameworks collaborate over A2A, each with MCP tools, all traced to Arize AX. The orchestrator reaches both through their agent cards, so the frameworks are interchangeable behind the protocol.

Component Framework Role
Bear Risk Analyst Pydantic AI Downside catalysts, with a hand-written A2A executor
Bull Market Analyst Google ADK Growth opportunities, using ADK's built-in A2A executor
Orchestrator Google ADK Calls both over A2A as tools

Fixes found by running it

The notebook cannot run today. google-adk requires a2a-sdk>=0.3.4,<0.4.0, but a2a-sdk 1.x removed a2a.server.apps, a2a.types.TextPart, a2a.types.TransportProtocol, and a2a.utils.new_agent_text_message. The unpinned install resolves to 1.x and none of the imports work. Now pinned in requirements.txt.

Agent(instrument=True) was removed in pydantic-ai 2.x, which crashed the Bear agent. Worse, the orchestrator absorbed the failure and answered that no risk signal was found instead of erroring. Tracing now uses Agent.instrument_all().

register() then add_span_processor() silently disables tracing. That call shuts down the default Arize exporter, and the OpenInference processor only translates spans, so the process exports nothing. The processor now goes through register(span_processors=[...]).

The Bear executor built its agent outside its try, so a build failure escaped as a server-level JSON-RPC error rather than a failed A2A task.

MCP servers launch with sys.executable and run as modules, instead of "python" plus a path that depends on the working directory.

Credentials

None in the code. Arize and model keys come from the environment, with an empty .env.example and .env gitignored.

Note separately: the existing notebook has a live Arize API key hardcoded in cells 49 and 60, public since the Copybara import. This PR does not touch that notebook; the key needs rotating regardless, since it is in git history.

Verification

Verified end to end with MODEL_PROVIDER=openai: A2A discovery and calls, both agents' MCP tools, the orchestrator, and 486 spans across 13 traces in Arize AX with all six MCP tools appearing as TOOL spans. Static checks clean on Python 3.12.

🤖 Generated with Claude Code

Turns the A2A multi-agent notebook into a real project. The notebook built its own
file tree at runtime by writing triple-quoted strings to disk; those are now actual
modules, so the code can be read, imported, and run without a notebook.

Two agents on different frameworks (Pydantic AI Bear, Google ADK Bull) collaborate
over A2A, each with MCP tools, all traced to Arize AX. The orchestrator reaches both
through their agent cards, so the frameworks are interchangeable behind the protocol.

Fixes found by running it:

- a2a-sdk is pinned to >=0.3.4,<0.4. google-adk requires that range, and a2a-sdk 1.x
  removed a2a.server.apps, a2a.types.TextPart, a2a.types.TransportProtocol, and
  a2a.utils.new_agent_text_message. The notebook's unpinned install resolves to 1.x,
  where none of its imports work.
- Agent(instrument=True) was removed in pydantic-ai 2.x, which crashed the Bear agent.
  The orchestrator absorbed the failure and reported that no risk signal was found
  rather than surfacing an error. Tracing now uses Agent.instrument_all().
- register() followed by add_span_processor() shuts down the default Arize exporter,
  so that pattern sends no spans at all. The OpenInference processor for Pydantic AI
  is passed through register(span_processors=[...]) instead.
- The Bear executor built its agent outside its try block, so a build failure escaped
  as a server-level JSON-RPC error instead of a failed A2A task.
- MCP servers launch with sys.executable and run as modules, rather than "python" with
  a path that depends on the working directory.

No credentials in the code: Arize and model keys come from the environment, with a
.env.example placeholder and .env gitignored.

Verified end to end with MODEL_PROVIDER=openai: A2A discovery and calls, both agents'
MCP tools, the orchestrator, and 486 spans across 13 traces in Arize AX. The Vertex
model bindings and Agent Engine deployment follow the Vertex API but were not run,
since they need a billed Google Cloud project. The README says so.
Removes the OpenAI provider switch entirely: config exposes Vertex model ids directly,
and the openai pin is dropped from requirements since litellm already requires it
transitively and ADK needs litellm to reach Llama regardless.

The provider switch existed so the A2A and tracing layers could be exercised without a
Google Cloud project. That verification stands, since those layers do not depend on
which model answers, and the README now states plainly which parts were run and which
were only reviewed against the installed SDKs.
Internal testing status is not useful to someone following the tutorial. The two
remaining notes stay because a reader hits both: the a2a-sdk pin explains why to install
from requirements.txt, and the shutdown warning is something they will see on screen.
@PatriciaArnedo
PatriciaArnedo merged commit cf52047 into main Aug 5, 2026
1 check passed
@PatriciaArnedo
PatriciaArnedo deleted the a2a-trading-agents branch August 5, 2026 17:27
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.

2 participants