feat(jaeger): implement ag-ui endpoint#8505
Conversation
Signed-off-by: Nabil-Salah <nabil.salah203@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR updates Jaeger Query’s AI gateway /api/ai/chat endpoint to speak the AG-UI protocol on the wire (AG-UI RunAgentInput in, AG-UI SSE events out) and completes the end-to-end wiring for per-turn “contextual tools” so the sidecar can dispatch UI tool calls back through the gateway with a fire-and-forget acknowledgement.
Changes:
- Switch the chat request/response shape to AG-UI (
RunAgentInput+text/event-stream) and translate ACP session updates into structured AG-UI lifecycle/text/tool-call SSE events. - Implement translation helpers for extracting the latest user message + context entries and for tool snapshot encoding.
- Wire contextual tools end-to-end: attach prefixed tools in
NewSessionRequest.Meta, store an unprefixed per-session snapshot, and validate/ack contextual tool dispatches in the ACP extension method handler.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/ai-sidecar/gemini/README.md | Documents fire-and-forget contextual tool ack semantics. |
| go.mod | Adds the AG-UI Go SDK dependency. |
| go.sum | Records checksums for the new AG-UI Go SDK dependency. |
| docs/rfc/0002-ai-gateway-contextual-tools.md | Updates the RFC to AG-UI request/response shapes and fire-and-forget tool rationale/flows. |
| cmd/jaeger/internal/extension/jaegerquery/internal/server_test.go | Updates router registration tests to use the new AG-UI request body shape. |
| cmd/jaeger/internal/extension/jaegerquery/internal/jaegerai/translation.go | Adds AG-UI → ACP prompt/tool translation helpers. |
| cmd/jaeger/internal/extension/jaegerquery/internal/jaegerai/translation_test.go | Unit tests for translation helpers and edge cases. |
| cmd/jaeger/internal/extension/jaegerquery/internal/jaegerai/streaming_client.go | Reworks streaming client to emit AG-UI SSE events from ACP updates and lifecycle calls. |
| cmd/jaeger/internal/extension/jaegerquery/internal/jaegerai/streaming_client_test.go | Adds/updates tests for SSE framing, lifecycle events, text, and tool-call event mapping. |
| cmd/jaeger/internal/extension/jaegerquery/internal/jaegerai/README.md | Updates package docs/diagrams to reflect AG-UI + SSE + fire-and-forget tools. |
| cmd/jaeger/internal/extension/jaegerquery/internal/jaegerai/handler.go | Switches chat handler to AG-UI input, builds ACP prompt blocks, wires tool snapshots/meta, and streams SSE. |
| cmd/jaeger/internal/extension/jaegerquery/internal/jaegerai/handler_test.go | Rewrites handler tests for the new AG-UI shape, SSE framing, meta/store wiring, and error signaling. |
| cmd/jaeger/internal/extension/jaegerquery/internal/jaegerai/dispatcher.go | Updates dispatcher/ext-method handling to validate against the store and return fire-and-forget acknowledgements. |
| cmd/jaeger/internal/extension/jaegerquery/internal/jaegerai/dispatcher_test.go | Expands dispatcher tests for store-backed validation and ack behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8505 +/- ##
==========================================
+ Coverage 96.53% 96.60% +0.06%
==========================================
Files 330 331 +1
Lines 17363 17578 +215
==========================================
+ Hits 16762 16981 +219
+ Misses 453 450 -3
+ Partials 148 147 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Nabil-Salah <nabil.salah203@gmail.com>
Signed-off-by: Nabil-Salah <nabil.salah203@gmail.com>
…h/jaeger into develop_agui_endpoint
Signed-off-by: Nabil-Salah <nabil.salah203@gmail.com>
Signed-off-by: Nabil-Salah <nabil.salah203@gmail.com>
|
needs a rebase |
Signed-off-by: Nabil-Salah <nabil.salah203@gmail.com>
Signed-off-by: Nabil-Salah <nabil.salah203@gmail.com>
Signed-off-by: Nabil-Salah <nabil.salah203@gmail.com>
CI Summary ReportMetrics Comparison✅ No significant metric changes Code Coverage✅ Coverage 97.3% (baseline 97.3%) ➡️ View CI run | View publish logs |
Signed-off-by: Nabil-Salah <nabil.salah203@gmail.com>
Signed-off-by: Nabil-Salah <nabil.salah203@gmail.com>
Which problem is this PR solving?
Description of the changes
ChatRequestto AG-UI'saguitypes.RunAgentInputshape (messages,tools,context,threadId,runId) and translate it into ACP prompt blocks via a newtranslation.go(latestUserMessageText,contextTextEntries,encodeToolsAsRaw,extractText).text/event-streamand havestreamingClientemit AG-UI lifecycle + content events (RUN_STARTED,TEXT_MESSAGE_START/CONTENT/END,TOOL_CALL_START/ARGS/RESULT/END,RUN_FINISHED,RUN_ERROR). Replaces the old[tool_call]/[tool_result]text markers.req.Tools, attaches theUIToolPrefix-prefixed snapshot toNewSessionRequest.Metaunderjaegertracing.io/contextual-tools, and writes the unprefixed snapshot intoContextualToolsStorekeyed by the assigned ACPSessionId.defer DeleteForSessionat turn end.handleJaegerToolCallvalidates payload, strips theui_prefix, looks the post-strip name up in the per-session snapshot, returns{result: {acknowledged: true}, isError: false}on hit andInvalidParamson miss.newDispatchernow takes*ContextualToolsStore; anilstore rejects every dispatch as not-registered. Browser performs the side effect locally based on the parallelTOOL_CALL_*SSE events — no synchronous tool result is round-tripped through the LLM.ContextualToolsMetaKeyconstant alongsideExtMethodJaegerToolCallandUIToolPrefixindispatcher.goso the protocol contracts live in one place.Cwd: "/"inNewSessionRequest(the gateway advertises no fs capability; ACP just requires the field non-empty).github.1485827954.workers.dev/ag-ui-protocol/ag-ui/sdks/community/goas a direct dependency.jaegerai/README (architecture diagram, request flow, contextual-tools lifecycle), thescripts/ai-sidecar/gemini/README (ack semantics), and RFC 0002 (fire-and-forget rationale §6.6, edge cases §6.7, implementation plan §7, open questions §8, protocol shapes §9.2).How was this change tested?
translation_test.go— 13 tests covering user-message extraction (latest-user, error-when-none, blank skip,InputContentparts), context-entry formatting (description + value, blank filter), tool encoding (round-trip, skip-unmarshalable), andextractTextacross all branches (string,[]InputContent,[]any, top-leveltext/parts,RawMessagedirect string, channel-marshal failure).streaming_client_test.goadditions — SSE-frame parsing helper,startRun/finishRun/failRun/ensureTextStartlifecycle,writeSSEEventsilently drops unmarshalable, idempotentensureTextStart, agent message →TEXT_MESSAGE_CONTENT,ToolCall→TOOL_CALL_START+TOOL_CALL_ARGS,ToolCallUpdate→TOOL_CALL_ARGS+TOOL_CALL_RESULT+TOOL_CALL_END(only oncompleted/failed),in_progressskipped.handler_test.gorewritten for the new request shape: ACP protocol assertions, context-entry → prompt block append, Meta carries prefixed tools, store set-then-cleared, omitted-Meta when no tools,RUN_FINISHED.stopReasonpropagation,threadId/runIdpropagation, no-user-message rejection, SSE content-type,RUN_ERRORframing on Prompt failure.dispatcher_test.goadditions —freshDispatcherreturns adispatcherFixture(revive function-result-limit fix); store-lookup hit, miss-on-unknown-tool, miss-on-unknown-session, miss-on-nil-store. Existing prefix-strip and warn-on-missing-prefix tests now seed the store before dispatching.test_sidecar_workflow.py) still passes.go buildand focusedgo teston every touched package.Checklist
make lint testAI Usage in this PR (choose one)
See AI Usage Policy.