[ 
https://issues.apache.org/jira/browse/CAMEL-27312?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen reassigned CAMEL-27312:
-----------------------------------

    Assignee: Claus Ibsen

> camel-jbang - the MCP server shows the agent runs, model calls and tool calls 
> of the GenAI spans
> ------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27312
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27312
>             Project: Camel
>          Issue Type: Sub-task
>          Components: camel-jbang
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>            Priority: Major
>             Fix For: 4.24.0
>
>
> CAMEL-27131 records GenAI spans at three levels 
> ({{camel.aiObservability.level}}): {{basic}} has one span per model call, 
> {{detailed}} adds the agent runs ({{invoke_agent}}) with their model calls 
> and tool calls ({{execute_tool}}), and {{full}} adds the messages. 
> CAMEL-27135 shows them in the Camel TUI: the AI usage view counts only the 
> model calls, the Spans tab labels the GenAI spans and summarizes an agent 
> run, and {{t}} shows the conversation of a span (apache/camel#30521, #30522, 
> #30523).
> An AI coding agent that uses the Camel MCP server sees none of this yet:
> * {{camel_runtime_ai_trace}} combines the message history, the processor 
> statistics and the route structure. It reads no spans, so it has no agent 
> runs, no tool calls and no per-call tokens.
> * {{camel_runtime_spans}} returns the raw span dump (100 spans by default). 
> The GenAI data is there, but the agent has to rebuild the tree itself, and at 
> level {{full}} each message attribute is a JSON string of up to 8192 
> characters per text.
> *Proposal*
> Make {{camel_runtime_ai_trace}} (or a new tool next to it) read the span dump 
> ({{get_spans}}) and add:
> # *Model calls*: per model the calls, input, output and cached tokens, 
> latency and finish reasons. Only model operations count, not 
> {{invoke_agent}}, {{execute_tool}} or {{create_agent}} (the same rule as the 
> TUI).
> # *Agent runs* (level {{detailed}} and above): per run its model, its steps 
> in order (each model call with tokens and finish reason, each tool call with 
> its name and time), the token totals, and how its time splits into model 
> calls, tool calls and the rest.
> # *Conversation* (level {{full}}), only when asked with a parameter: the 
> messages of one run as turns (system, user, assistant, tool call with 
> arguments, tool result named after its tool). The last model call of a run 
> already holds the whole run. Content may hold personal data and can be large, 
> so it is opt-in and capped.
> # *The level the spans show*, worked out from their attributes as the TUI 
> does, with a hint when it is {{basic}} (agent runs and tool calls are not 
> traced) or when there are no GenAI spans ({{camel run --observe}} adds 
> camel-ai-observability when a GenAI component is used).
> *Reuse*
> The TUI already has this logic in camel-jbang-plugin-tui: 
> {{GenAiSpanUsageExtractor}}, {{GenAiSpanView}} and {{GenAiTranscript}}. 
> camel-jbang-mcp does not depend on the TUI plugin, so move the span model (no 
> TamboUI types; {{GenAiSpanView}} mixes in the rendering) to a module both 
> use, such as camel-jbang-core. Then the TUI and the MCP server count and 
> group the same way.
> Also update the tool description, which lists the AI components.
> Example to try it with: apache/camel-jbang-examples#140 ({{ai/agent-tools}}).
> _Created by Claude Code on behalf of Claus Ibsen_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to