Files
Alem Tuzlak 189eca6872 fix(showcase/ms-agent-python): modernize to gpt-5.2, native reasoning + multimodal, fix multi-turn A2UI
Removes obsolete workarounds and uses MAF's native primitives where the
framework supports them. Surfaces the genuine gaps as targeted shims.

Reasoning
  - delete the no-op `think` tool; configure `reasoning={effort,summary}`
    on the Agent default_options. AG-UI bridge already emits real
    REASONING_MESSAGE_* events from the Responses API.
  - bump `@ag-ui/client` 0.0.43 -> 0.0.52 so the frontend event schema
    includes REASONING_MESSAGE_* (0.0.43 was still on the deprecated
    THINKING_TEXT_MESSAGE_* union).
  - reasoning-block.tsx -> consume ReasoningMessage via the
    `messageView.reasoningMessage` slot; default-render demo strips
    its `useRenderTool(think)` and uses zero-config CopilotChat.

Multimodal
  - delete the frontend LegacyConverterShim that rewrote modern
    `{type:"image"|"document", source:...}` parts to legacy `binary`.
    MAF's AG-UI adapter handles the modern shape natively.
  - delete the pypdf extraction subclass; gpt-5.2 reads PDFs natively
    via OpenAI's `input_file`. Drop `pypdf` from requirements.
  - retain a tiny 30-line `_MultimodalAgent` + adapter monkey-patch
    that copies `metadata.filename` into Content.additional_properties
    so OpenAI's `input_file` requirement is satisfied (upstream gap
    in agent_framework_ag_ui._message_adapters._parse_multimodal_media_part).

A2UI dynamic
  - fix the flat ops shape bug in `build_a2ui_operations_from_tool_call`:
    middleware expects v0.9 nested `{createSurface:{surfaceId,catalogId}}`,
    not flat `{type:"create_surface",surfaceId,...}`. Flat shape silently
    fell back to surface group "default" and never rendered.
  - secondary structured-output call: use chat_client.client (underlying
    AsyncOpenAI) directly to bypass MAF's function-invocation auto-loop;
    inherits api_key + model from the parent. response_format=PydanticModel
    is unsuitable (strict-mode rejects open dicts); a one-shot raw-args
    primitive doesn't exist in agent_framework today.
  - inject the registered A2UI catalog schema (49KB of Zod types) from
    `input_data.context[]` into the secondary call's system prompt so the
    LLM emits correct prop names. _A2UIDynamicAgent captures the schema
    on each run().
  - switch the OUTER agent to OpenAIChatCompletionClient. Responses API
    + tool calls + multi-turn fails ("No tool output found for function
    call ...") because reasoning items can't be replayed; chat.completions
    replays tool history cleanly.
  - defensive _reorder_tool_messages shim: the CopilotKit frontend message
    store ships [user, tool, assistant(toolCalls), assistant, user] on
    turn 2 (tool BEFORE its parent assistant), which OpenAI rejects.
    Walk inbound messages and re-attach tool messages immediately after
    their matching assistant.toolCalls[].id. (Should be fixed upstream
    in @copilotkit/react-core/v2.)
  - tighten the render_a2ui JSON schema (minItems:1, explicit
    items.properties, strict:false) and the prompt header so gpt-5.x
    actually emits non-empty components with entry-level props.
  - same A2UI bypass replacement in agent.py + beautiful_chat.py (shared
    pattern, three call sites of the original `from openai import OpenAI`).

Model bump
  - default OPENAI_CHAT_MODEL_ID -> gpt-5.2 (Responses-capable reasoning
    model). Scoped clients: reasoning agent on gpt-5.2 + Responses;
    a2ui_dynamic on gpt-5.2 + chat.completions (avoids reasoning replay).

Upstream gaps surfaced (recommend follow-up PRs)
  - agent_framework_ag_ui: propagate part.metadata.filename to
    Content.additional_properties["filename"] in
    _parse_multimodal_media_part. (Removes the PDF subclass.)
  - agent_framework: a one-shot tool-args API
    (e.g. get_response(..., auto_invoke=False)) or a cleanly exported
    RawOpenAIChatClient. (Removes the A2UI raw-SDK bypass.)
  - @copilotkit/react-core/v2: stop reordering role=tool messages
    before their assistant parent in the frontend message store.
    (Removes the A2UI message-reorder shim.)
2026-05-12 15:06:11 +02:00

41 lines
1.2 KiB
JSON

{
"name": "@copilotkit/showcase-ms-agent-python",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "concurrently \"next dev --turbopack\" \"PYTHONPATH=. python -m uvicorn agent_server:app --host 0.0.0.0 --port 8000 --reload\"",
"build": "next build",
"start": "next start",
"lint": "next lint",
"test:e2e": "playwright test"
},
"dependencies": {
"@ag-ui/client": "^0.0.52",
"@copilotkit/a2ui-renderer": "next",
"@copilotkit/react-core": "next",
"@copilotkit/runtime": "next",
"@copilotkit/voice": "next",
"@hashbrownai/core": "0.5.0-beta.4",
"@hashbrownai/react": "0.5.0-beta.4",
"@json-render/core": "0.18.0",
"@json-render/react": "0.18.0",
"@radix-ui/react-checkbox": "^1.3.3",
"next": "^15.5.15",
"openai": "^5.9.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"recharts": "^2.15.0",
"zod": "^3.24.0"
},
"devDependencies": {
"@playwright/test": "^1.50.0",
"@tailwindcss/postcss": "^4.0.0",
"@types/node": "^22.0.0",
"@types/react": "^19.0.0",
"concurrently": "^9.1.0",
"postcss": "^8.5.0",
"tailwindcss": "^4.0.0",
"typescript": "^5.7.0"
}
}