feat(webui): draw each transcript entry with its Trace pattern (#1718)
Quality / check (pull_request) Successful in 3m38s
Quality / check (pull_request) Successful in 3m38s
Record the model's reasoning parts. The step run view shows reasoning as a Thought row, shell calls as a terminal, the gate as a test run, web_fetch as a source, finish as the verdict, and each fan-out branch as a subagent.
This commit is contained in:
5 files changed
+254
-113
No files matched your search
@@ -61,6 +61,7 @@ func (t *transcript) ModelCallFinished(_ context.Context, req chat.Request, resp
|
||||
}
|
||||
if resp != nil {
|
||||
entry.Text = clip(resp.Content, &entry.TextBytes)
|
||||
entry.Reasoning = clip(reasoning(resp.Parts), &entry.ReasoningBytes)
|
||||
entry.FinishReason = resp.FinishReason
|
||||
for _, call := range resp.ToolCalls {
|
||||
recorded := agentrun.TranscriptToolCall{ID: call.ID, Name: call.Name}
|
||||
@@ -130,6 +131,16 @@ func (t *transcript) AfterToolExecute(_ context.Context, call core.ToolCall, res
|
||||
t.add(entry)
|
||||
}
|
||||
|
||||
func reasoning(parts chat.Parts) string {
|
||||
var texts []string
|
||||
for _, part := range parts {
|
||||
if thought, ok := part.(chat.ReasoningPart); ok && thought.Text != "" {
|
||||
texts = append(texts, thought.Text)
|
||||
}
|
||||
}
|
||||
return strings.Join(texts, "\n\n")
|
||||
}
|
||||
|
||||
func isCompaction(req chat.Request) bool {
|
||||
n := len(req.Messages)
|
||||
return n > 0 && req.Messages[n-1].Role == chat.RoleUser && strings.HasPrefix(req.Messages[n-1].Content, compactionPrefix)
|
||||
|
||||
@@ -45,7 +45,7 @@ func (r Reporter) ReportTranscript(entry TranscriptEntry) {
|
||||
const (
|
||||
TranscriptSystem = "system" // Text: the system prompt
|
||||
TranscriptUser = "user" // Text: the mission, or input the loop added later
|
||||
TranscriptModel = "model" // Text and ToolCalls: one model response
|
||||
TranscriptModel = "model" // Reasoning, Text and ToolCalls: one model response
|
||||
TranscriptTool = "tool" // one tool call's arguments and result
|
||||
TranscriptCompaction = "compaction" // Text: the summary that replaced the history
|
||||
)
|
||||
@@ -60,6 +60,9 @@ type TranscriptEntry struct {
|
||||
TextBytes int `json:"text_bytes,omitempty"`
|
||||
ToolCalls []TranscriptToolCall `json:"tool_calls,omitempty"`
|
||||
|
||||
Reasoning string `json:"reasoning,omitempty"`
|
||||
ReasoningBytes int `json:"reasoning_bytes,omitempty"`
|
||||
|
||||
CallID string `json:"call_id,omitempty"`
|
||||
Tool string `json:"tool,omitempty"`
|
||||
Args string `json:"args,omitempty"`
|
||||
|
||||
Reference in new issue
Block a user