feat(client): add granular debug mode to AG-UI event pipeline - #1398
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Python Preview PackagesVersion
Install with uvAdd the TestPyPI index to your [[tool.uv.index]]
name = "testpypi"
url = "https://test.pypi.org/simple/"
explicit = trueThen install the packages you need: # Core SDK
uv add 'ag-ui-protocol==0.0.0.dev1775038397' --index testpypi
# Integrations (each already depends on the matching ag-ui-protocol preview)
uv add 'ag-ui-langgraph==0.0.0.dev1775038397' --index testpypi
uv add 'ag-ui-crewai==0.0.0.dev1775038397' --index testpypi
# NOTE: ag-ui-agent-spec depends on pyagentspec (git-only, not on PyPI).
# You will need to install pyagentspec separately from its git repo.
uv add 'ag-ui-agent-spec==0.0.0.dev1775038397' --index testpypi
uv add 'ag_ui_adk==0.0.0.dev1775038397' --index testpypi
uv add 'ag_ui_strands==0.0.0.dev1775038397' --index testpypiInstall with pippip install \
--index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple/ \
ag-ui-protocol==0.0.0.dev1775038397
Commit: 2e614fa |
Replace all scattered console.debug calls across 7 pipeline files with a centralized DebugLogger class that handles verbose vs summary output. Pipeline functions now accept DebugLogger | undefined instead of ResolvedAgentDebugConfig, and console.debug is only called from the single debug-logger.ts module.
@ag-ui/a2a-middleware
@ag-ui/a2ui-middleware
@ag-ui/mcp-apps-middleware
@ag-ui/middleware-starter
@ag-ui/a2a
@ag-ui/adk
@ag-ui/ag2
@ag-ui/agno
@ag-ui/aws-strands
@ag-ui/claude-agent-sdk
@ag-ui/crewai
@ag-ui/langchain
@ag-ui/langgraph
@ag-ui/langroid
@ag-ui/llamaindex
@ag-ui/mastra
@ag-ui/pydantic-ai
@ag-ui/server-starter
@ag-ui/server-starter-all-features
@ag-ui/vercel-ai-sdk
create-ag-ui-app
@ag-ui/client
@ag-ui/core
@ag-ui/encoder
@ag-ui/proto
commit: |
@ag-ui/a2a-middleware
@ag-ui/a2ui-middleware
@ag-ui/mcp-apps-middleware
@ag-ui/middleware-starter
@ag-ui/a2a
@ag-ui/adk
@ag-ui/ag2
@ag-ui/agno
@ag-ui/aws-strands
@ag-ui/claude-agent-sdk
@ag-ui/crewai
@ag-ui/langchain
@ag-ui/langgraph
@ag-ui/langroid
@ag-ui/llamaindex
@ag-ui/mastra
@ag-ui/pydantic-ai
@ag-ui/server-starter
@ag-ui/server-starter-all-features
@ag-ui/vercel-ai-sdk
create-ag-ui-app
@ag-ui/client
@ag-ui/core
@ag-ui/encoder
@ag-ui/proto
commit: |
| if (debug) { | ||
| console.debug("[VERIFY]:", JSON.stringify(event)); | ||
| } | ||
| log?.event("VERIFY", "", event, { type: event.type }); |
There was a problem hiding this comment.
The label here is "" so the output comes out as "[VERIFY] " with a trailing space. Every other stage uses a descriptive label ("Event received:", "Event applied:", etc.). Probably wants to be "Event:" or similar to stay consistent.
| if (this.debug) { | ||
| console.debug("[LEGACY]:", JSON.stringify(event)); | ||
| } | ||
| this.debugLogger?.event("LEGACY", "", event, { type: (event as any).type }); |
There was a problem hiding this comment.
LegacyRuntimeProtocolEvent should have .type typed already. Worth checking if it can come off here.
|
|
||
| // Either the event is invalid and logged, or the schema was lenient. | ||
| // If the schema rejects it, we should see the invalid log. | ||
| if (errorCaught) { |
There was a problem hiding this comment.
If the schema parser doesn't reject the invalid event type, errorCaught stays false and the expect never runs, the test passes without asserting anything. expect.assertions(1) at the top of the test would catch that and make the intent explicit.
- Add descriptive "Event:" label to VERIFY and LEGACY log calls - Make debugLogger accept boolean for backward compatibility via getter/setter - Remove unnecessary (event as any).type cast on LegacyRuntimeProtocolEvent - Add expect.assertions(1) to ensure invalid event test always asserts
## Summary
- Add `debug` option to `CopilotRuntime` constructor and `<CopilotKit>`
provider for detailed event pipeline logging
- Server-side uses Pino structured logger; client-side uses
`console.debug` at each AG-UI pipeline stage
- Accepts `true` for full output or a granular config: `{ events,
lifecycle, verbose }`
- The two toggles are independent — enabling debug on the client does
not affect the server
## Changes
**`@copilotkit/shared`**
- New `DebugConfig` type, `ResolvedDebugConfig` interface,
`resolveDebugConfig()` normalizer
**`@copilotkit/runtime`**
- `debug` option on `CopilotRuntime({ debug: true })`
- Lifecycle logging: agent run started, SSE stream
opened/completed/errored
- Event logging: every emitted event (verbose = full payload, otherwise
key fields summary)
**`@copilotkit/react-core` + `@copilotkit/core`**
- `debug` prop on `<CopilotKit debug={true}>`
- Threads config through `CopilotKitCore` → `AgentRegistry` →
`ProxiedCopilotRuntimeAgent`
**Companion PR:** ag-ui-protocol/ag-ui#1398 (AG-UI client-side debug
logging)
## Test plan
- [x] All 647 runtime tests pass
- [x] All 352 AG-UI client tests pass
- [x] Lint clean (0 errors)
- [x] All affected packages build successfully
- [ ] Manual: set `debug: true` on runtime and provider, verify
structured logs on server and console output on client
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Summary
AbstractAgent.debugfrombooleanto accept a granular config object withevents,lifecycle, andverboseflagsdebug: true, all categories are enabled with full verbose payloads{ events: true, lifecycle: false }), each category can be toggled independentlyChanges
agent/types.ts— NewResolvedAgentDebugConfig,AgentDebugConfigtypes andresolveAgentDebugConfig()resolveragent/agent.ts—debugproperty nowResolvedAgentDebugConfig, lifecycle logging inrunAgent/catchError/finalizeagent/http.ts— Pass debug config totransformHttpEventStreamtransform/sse.ts— Log received SSE eventstransform/http.ts— Log stream format detection and event validationchunks/transform.ts— Expand existing debug logging with verbose/summary branchingverify/verify.ts— Expand existing debug logging with verbose/summary branchingapply/default.ts— Log applied/dropped events with subscriber infoTest plan
debug: trueon an agent and verify console output at each pipeline stage