Skip to content

πŸ› Bug: AG-UI ADK Auth crashes: Object of type SecuritySchemeType is not JSON serializableΒ #2725

@rcleveng

Description

@rcleveng

♻️ Reproduction Steps

If you try to enable Auth for any ADK action, then AG-UI's middleware throws an exception.

See google/adk-python#3288 - but this is on the AG-UI middleware.

Any ideas what a fix would look like?

βœ… Expected Behavior

I expect it to not crash

❌ Actual Behavior

It crashed

𝌚 CopilotKit Version

@copilotkit/react-core 1.10.6
@copilotkit/react-ui 1.10.6
@copilotkit/runtime 1.10.6

πŸ“„ Logs (Optional)

2025-11-16 06:59:00,588 - ag_ui_adk.adk_agent - ERROR - Background execution error: Object of type SecuritySchemeType is not JSON serializable
Traceback (most recent call last):
  File "/Users/r/git/lairo/app-be/backend/agent_api/.venv/lib/python3.14/site-packages/ag_ui_adk/adk_agent.py", line 1102, in _run_adk_in_background
    async for ag_ui_event in event_translator.translate_lro_function_calls(
    ...<5 lines>...
        logger.debug(f"Event queued: {type(ag_ui_event).__name__} (thread {input.thread_id}, queue size after: {event_queue.qsize()})")
  File "/Users/r/git/lairo/app-be/backend/agent_api/.venv/lib/python3.14/site-packages/ag_ui_adk/event_translator.py", line 443, in translate_lro_function_calls
    args_str = json.dumps(long_running_function_call.args) if isinstance(long_running_function_call.args, dict) else str(long_running_function_call.args)
               ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/r/.local/share/uv/python/cpython-3.14.0-macos-aarch64-none/lib/python3.14/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
           ~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/Users/r/.local/share/uv/python/cpython-3.14.0-macos-aarch64-none/lib/python3.14/json/encoder.py", line 200, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/Users/r/.local/share/uv/python/cpython-3.14.0-macos-aarch64-none/lib/python3.14/json/encoder.py", line 261, in iterencode
    return _iterencode(o, 0)
  File "/Users/r/.local/share/uv/python/cpython-3.14.0-macos-aarch64-none/lib/python3.14/json/encoder.py", line 180, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
                    f'is not JSON serializable')
TypeError: Object of type SecuritySchemeType is not JSON serializable
when serializing dict item 'type'
when serializing dict item 'authScheme'
when serializing dict item 'authConfig'
2025-11-16 06:59:00,590 - google_adk.google.adk.runners - INFO - Closing toolset: ClientProxyToolset
2025-11-16 06:59:00,590 - ag_ui_adk.client_proxy_toolset - INFO - Closing ClientProxyToolset
2025-11-16 06:59:00,590 - google_adk.google.adk.runners - INFO - Successfully closed toolset: ClientProxyToolset
2025-11-16 06:59:00,596 - ag_ui_adk.session_manager - INFO - Updated state for session Project Apprentice:9cda2234-ffac-4d55-b834-13e1cf4d8b09
2025-11-16 06:59:00,596 - ag_ui_adk.adk_agent - INFO - Added tool call adk-d05dd57e-cccd-4e76-a6ce-b4114cfd5bb2 to session 9cda2234-ffac-4d55-b834-13e1cf4d8b09 pending list
2025-11-16 06:59:00,599 - ag_ui_adk.adk_agent - INFO - Preserving execution for thread 9cda2234-ffac-4d55-b834-13e1cf4d8b09 - has pending tool calls (HITL scenario)
2025-11-16 06:59:00,599 - opentelemetry.context - ERROR - Failed to detach context
Traceback (most recent call last):
  File "/Users/r/git/lairo/app-be/backend/agent_api/.venv/lib/python3.14/site-packages/opentelemetry/trace/__init__.py", line 589, in use_span
    yield span
  File "/Users/r/git/lairo/app-be/backend/agent_api/.venv/lib/python3.14/site-packages/opentelemetry/sdk/trace/__init__.py", line 1105, in start_as_current_span
    yield span
  File "/Users/r/git/lairo/app-be/backend/agent_api/.venv/lib/python3.14/site-packages/opentelemetry/trace/__init__.py", line 454, in start_as_current_span
    yield span
  File "/Users/r/git/lairo/app-be/backend/agent_api/.venv/lib/python3.14/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 801, in _call_llm_with_tracing
    yield llm_response
GeneratorExit

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions