Skip to content

Conversation

@Ilevk
Copy link
Contributor

@Ilevk Ilevk commented Nov 19, 2025

Description

Tests

Before

Prompt: tell me my usdc balance in my account
Traceback (most recent call last):
  File "/Users/dable/Desktop/Base/dev/agentkit/python/examples/pydantic-ai-cdp-chatbot/chatbot.py", line 97, in <module>
    asyncio.run(main())
  File "/Users/dable/Desktop/Base/dev/agentkit/python/examples/pydantic-ai-cdp-chatbot/.venv/lib/python3.10/site-packages/nest_asyncio.py", line 30, in run
    return loop.run_until_complete(task)
  File "/Users/dable/Desktop/Base/dev/agentkit/python/examples/pydantic-ai-cdp-chatbot/.venv/lib/python3.10/site-packages/nest_asyncio.py", line 98, in run_until_complete
    return f.result()
  File "/Users/dable/.local/share/uv/python/cpython-3.10.13-macos-aarch64-none/lib/python3.10/asyncio/futures.py", line 201, in result
    raise self._exception.with_traceback(self._exception_tb)
  File "/Users/dable/.local/share/uv/python/cpython-3.10.13-macos-aarch64-none/lib/python3.10/asyncio/tasks.py", line 232, in __step
    result = coro.send(None)
  File "/Users/dable/Desktop/Base/dev/agentkit/python/examples/pydantic-ai-cdp-chatbot/chatbot.py", line 90, in main
    await run_chat_mode(agent=agent)
  File "/Users/dable/Desktop/Base/dev/agentkit/python/examples/pydantic-ai-cdp-chatbot/chatbot.py", line 49, in run_chat_mode
    output = await agent.run(user_input, message_history=history)
  File "/Users/dable/Desktop/Base/dev/agentkit/python/examples/pydantic-ai-cdp-chatbot/.venv/lib/python3.10/site-packages/pydantic_ai/agent.py", line 562, in run
    async for _ in agent_run:
  File "/Users/dable/Desktop/Base/dev/agentkit/python/examples/pydantic-ai-cdp-chatbot/.venv/lib/python3.10/site-packages/pydantic_ai/agent.py", line 2178, in __anext__
    next_node = await self._graph_run.__anext__()
  File "/Users/dable/Desktop/Base/dev/agentkit/python/examples/pydantic-ai-cdp-chatbot/.venv/lib/python3.10/site-packages/pydantic_graph/graph.py", line 809, in __anext__
    return await self.next(self._next_node)
  File "/Users/dable/Desktop/Base/dev/agentkit/python/examples/pydantic-ai-cdp-chatbot/.venv/lib/python3.10/site-packages/pydantic_graph/graph.py", line 782, in next
    self._next_node = await node.run(ctx)
  File "/Users/dable/Desktop/Base/dev/agentkit/python/examples/pydantic-ai-cdp-chatbot/.venv/lib/python3.10/site-packages/pydantic_ai/_agent_graph.py", line 299, in run
    return await self._make_request(ctx)
  File "/Users/dable/Desktop/Base/dev/agentkit/python/examples/pydantic-ai-cdp-chatbot/.venv/lib/python3.10/site-packages/pydantic_ai/_agent_graph.py", line 359, in _make_request
    model_response = await ctx.deps.model.request(message_history, model_settings, model_request_parameters)
  File "/Users/dable/Desktop/Base/dev/agentkit/python/examples/pydantic-ai-cdp-chatbot/.venv/lib/python3.10/site-packages/pydantic_ai/models/openai.py", line 244, in request
    response = await self._completions_create(
  File "/Users/dable/Desktop/Base/dev/agentkit/python/examples/pydantic-ai-cdp-chatbot/.venv/lib/python3.10/site-packages/pydantic_ai/models/openai.py", line 311, in _completions_create
    openai_messages = await self._map_messages(messages)
  File "/Users/dable/Desktop/Base/dev/agentkit/python/examples/pydantic-ai-cdp-chatbot/.venv/lib/python3.10/site-packages/pydantic_ai/models/openai.py", line 466, in _map_messages
    tool_calls.append(self._map_tool_call(item))
  File "/Users/dable/Desktop/Base/dev/agentkit/python/examples/pydantic-ai-cdp-chatbot/.venv/lib/python3.10/site-packages/pydantic_ai/models/openai.py", line 485, in _map_tool_call
    return chat.ChatCompletionMessageToolCallParam(
  File "/Users/dable/.local/share/uv/python/cpython-3.10.13-macos-aarch64-none/lib/python3.10/typing.py", line 957, in __call__
    result = self.__origin__(*args, **kwargs)
  File "/Users/dable/.local/share/uv/python/cpython-3.10.13-macos-aarch64-none/lib/python3.10/typing.py", line 387, in __call__
    raise TypeError(f"Cannot instantiate {self!r}")
TypeError: Cannot instantiate typing.Union

After

Chatbot: python/examples/pydantic-ai-cdp-chatbot/chatbot.py
Network: Base Sepolia
Setup: Check USDC balance

Prompt:usdc balance 

---------------------------------
Your wallet 0xc3A5F395d8D626e0690199b15A9319db110cbE7E on base-sepolia holds 1 USDC (contract 0x036CbD53842c5426634e7929541eC2318f3dCF7e)
---------------------------------

Checklist

A couple of things to include in your PR for completeness:

  • Added documentation to all relevant README.md files
  • Added a changelog entry

@cb-heimdall
Copy link

cb-heimdall commented Nov 19, 2025

✅ Heimdall Review Status

Requirement Status More Info
Reviews 1/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

@github-actions github-actions bot added the example New example agent label Nov 19, 2025
@Ilevk Ilevk marked this pull request as ready for review November 19, 2025 14:53
@Ilevk Ilevk requested a review from murrlincoln as a code owner November 19, 2025 14:53
@Ilevk Ilevk changed the title fix - update openai version fix: typing.Union Instantiation Error in Tool Usage (OpenAI Version Fix) Nov 19, 2025
@Ilevk Ilevk marked this pull request as draft November 19, 2025 14:54
@Ilevk Ilevk force-pushed the fix/openai-dependency branch from f88bd02 to 5285d58 Compare November 19, 2025 14:58
@github-actions github-actions bot added documentation Improvements or additions to documentation framework extension New framework extension and removed example New example agent labels Nov 19, 2025
@Ilevk Ilevk marked this pull request as ready for review November 19, 2025 15:00
@github-actions github-actions bot added the example New example agent label Nov 19, 2025
@Ilevk Ilevk marked this pull request as draft November 19, 2025 15:04
@Ilevk Ilevk force-pushed the fix/openai-dependency branch from ae43df7 to c26cf4a Compare November 19, 2025 15:16
@Ilevk Ilevk marked this pull request as ready for review November 19, 2025 15:16
@phdargen
Copy link
Contributor

Thanks for the fix @Ilevk, looks great!

Could you please revert the manual Changelog edit and instead use towncrier as described here: https://github.com/coinbase/agentkit/blob/main/CONTRIBUTING-PYTHON.md#changelog

Please run it inpython/framework-extensions/pydantic-ai

@Ilevk Ilevk force-pushed the fix/openai-dependency branch from 3c65d0f to cf876e7 Compare December 17, 2025 14:03
@github-actions github-actions bot added documentation Improvements or additions to documentation and removed documentation Improvements or additions to documentation labels Dec 17, 2025
@Ilevk Ilevk force-pushed the fix/openai-dependency branch from 3bf664c to 561974a Compare December 17, 2025 14:09
@Ilevk
Copy link
Contributor Author

Ilevk commented Dec 17, 2025

I've rebase with latest main branch and create change log as following guidance.

@phdargen phdargen merged commit 9f3c578 into coinbase:main Dec 17, 2025
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation example New example agent framework extension New framework extension python

Development

Successfully merging this pull request may close these issues.

3 participants