davsclaus opened a new pull request, #30522:
URL: https://github.com/apache/camel/pull/30522

   _Claude Code on behalf of Claus Ibsen_
   
   ## What
   
   Second part of 
[CAMEL-27135](https://issues.apache.org/jira/browse/CAMEL-27135), after #30521 
(the AI usage view counts only model calls). The two PRs don't depend on each 
other.
   
   At GenAI observability level `full` (CAMEL-27131), the spans carry the 
messages as JSON strings: `gen_ai.system_instructions`, 
`gen_ai.input.messages`, `gen_ai.output.messages`, and the arguments and result 
of a tool call. Until now the Spans tab showed each of them as one line in the 
detail panel of the waterfall.
   
   This PR makes them readable:
   
   - **`GenAiTranscript`** builds the conversation from the messages, which 
follow the OpenTelemetry GenAI semantic conventions (`role`, `parts` of `text`, 
`reasoning`, `tool_call`, `tool_call_response`, `finish_reason`). It gives:
     - the system instructions, which are not repeated when the input already 
has a system message
     - the user and assistant messages
     - each tool call with its arguments, and its result named after the tool 
(found through the call id)
     - the finish reason
   
     An agent run (`invoke_agent`) shows its last model call, whose input 
already holds the whole run, so nothing needs stitching. A tool call 
(`execute_tool`) shows its arguments and result.
   - **`t`** on a GenAI span in the waterfall opens the conversation as 
Markdown over the waterfall (`TranscriptOverlay`). Tool data shows as JSON code 
blocks, texts cut at `contentMaxLength` are marked *(truncated)*, and `Esc` 
closes it.
   - **The detail panel** of a GenAI span says whether `t` has messages to 
show, or that they are only recorded at `camel.aiObservability.level=full`. The 
footer shows `t conversation` on GenAI spans.
   
   The last PR of CAMEL-27135 adds GenAI labels to the waterfall and a summary 
of the agent run in the detail panel.
   
   ## Tried live
   
   A camel-openai agent on Ollama (`llama3.2`) with one `ai-tool` route tool, 
run at `camel.aiObservability.level=full`. `t` on the `invoke_agent` span of 
one run:
   
   ![The conversation of an agent 
run](https://raw.githubusercontent.com/apache/camel/CAMEL-27135-genai-transcript/docs/user-manual/modules/ROOT/images/jbang/camel-tui-spans-conversation.png)
   
   ## Tests
   
   - `GenAiTranscriptTest`:
     - a model call, an agent run (with its last model call nested under a 
Camel span), and an agent run with no model calls
     - system instructions are not repeated, and a tool call shows its 
arguments and result
     - spans without messages, and values that are not JSON
     - the Markdown output: headings, JSON code blocks, cut texts, and fences 
that content can't close
   - `SpansTabRenderTest`: `t` opens and `Esc` closes the conversation, the 
footer, and the level message for a span without messages
   - `camel-jbang-plugin-tui`: all 2647 tests pass
   
   Docs: the Spans section of `camel-jbang-tui-observe.adoc` (with the 
screenshot) and the Spans help page of the TUI.
   
   🤖 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]

Reply via email to