davsclaus opened a new pull request, #30525: URL: https://github.com/apache/camel/pull/30525
_Claude Code on behalf of Claus Ibsen_ ## What [CAMEL-27312](https://issues.apache.org/jira/browse/CAMEL-27312). The GenAI observability (CAMEL-27131) records model calls, agent runs (`invoke_agent`), tool calls (`execute_tool`) and, at level `full`, the messages as spans. The Camel TUI shows them since CAMEL-27135 (#30521, #30522, #30523). Over MCP, an AI coding agent saw none of it: - `camel_runtime_ai_trace` read no spans - `camel_runtime_spans` gives the raw dump, where each message is a JSON string of up to 8k characters **One span model for the TUI and the MCP server.** The TUI's span model moves to camel-jbang-core (`org.apache.camel.dsl.jbang.core.common.genai`): - `SpanEntry` - `GenAiSpans`: model call / agent run / tool call, provider, model, and the level the spans show - `GenAiAgentRuns`: the runs with their steps, the exchange id and the question - `GenAiTranscript` The TUI keeps only its rendering. camel-jbang-core gets `camel-ai-observability-api` (it depends only on camel-support) for the attribute names. **`camel_runtime_ai_trace` starts with the GenAI spans.** - `genAiSummary` comes first and fits in what a chat history keeps of a tool result (400 characters), for example `GenAI level=full: 3 agent runs, 6 model calls (granite4:3b), 4 tool calls; runs newest first. camel_runtime_ai_conversation with a runId shows the messages of a run.` - Without GenAI spans, it says how to turn them on (`camel run --observe`, `camel.aiObservability.level=detailed`). At level `basic`, it says that agent runs and tool calls are not traced. - `genAi` has the model calls per model (tokens in, out and cached; average time; finish reasons), and the newest 5 agent runs with "+N more". Each run has its `runId`, route, exchange id, start, time, tokens and its steps in order. - At level `full`, a run also has its question (the first user message) and the tool arguments and results, cut at 200 characters. That lets a model map "how was question 3 answered" to a run without another call. - The history-based part of the answer is unchanged and follows. **New `camel_runtime_ai_conversation`.** It takes one required argument, the `runId` from the trace. It returns the messages of the run in order, cut at 1,000 characters a text and 6,000 in all, and says what was cut. It's a separate, opt-in call because the messages can hold customers' data. Every answer states the level. The spans are read without `McpToolNames`, so recorded messages stay as they were. A dump that can't be read counts as no spans, not an error of the whole call. The shape follows the input of the local model benchmark work: summary first, shallow, newest 5, the TUI's words, a separate conversation tool with one required argument. @Croway, you own the MCP tool consolidation (CAMEL-25639 and the related tickets). Are you OK with extending `camel_runtime_ai_trace` and adding `camel_runtime_ai_conversation` as a dedicated tool? ## Tried live The `ai/agent-tools` example (apache/camel-jbang-examples#140: camel-openai on Ollama `granite4:3b` with two route tools), run with `camel run --observe` at level `full`. Then the MCP server of this branch over stdio: - `camel_runtime_ai_trace` answers in 3,949 characters. The summary is first, and the run of question 3 lists `order_status {"orderId":"ORD-1003"}` and `stock_level {"sku":"CAMEL-CAP"}` with their results. - `camel_runtime_ai_conversation` with that `runId` returns the 7 message parts in order, ending with "Your order ORD-1003 is still pending and the Camel cap is currently out of stock." ## Tests - camel-jbang-core: `GenAiAgentRunsTest` (new) and `GenAiTranscriptTest` (moved from the TUI) - camel-jbang-mcp: - `GenAiTraceReportTest` (new): the summary, runs and steps, the newest 5, level `basic`, no spans, the route filter, the dump, and the conversation with its caps - `RuntimeToolsWiringTest`: the new tool's required `runId` and its hints - all 484 tests of the module pass - camel-jbang-plugin-tui: all tests pass on the moved model. The `AiPanel.java` cap of `SourceSizeTest` goes up by one line, for the import of the moved `SpanEntry`. Docs: the MCP tools table in `camel-jbang-mcp.adoc`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
