sketch: add debug handler to dump conversation history as JSON
Add HTTP debug endpoint /debug/conversation-history to dump agent conversation
history as pretty-printed JSON for debugging purposes.
Sometimes, you just want to see what went on.
Co-Authored-By: sketch <hello@sketch.dev>
Change-ID: s6c9e876db9b3aa5ck
diff --git a/loop/agent.go b/loop/agent.go
index ed5c907..1416ab6 100644
--- a/loop/agent.go
+++ b/loop/agent.go
@@ -335,6 +335,7 @@
ToolResultCancelContents(resp *llm.Response) ([]llm.Content, error)
CancelToolUse(toolUseID string, cause error) error
SubConvoWithHistory() *conversation.Convo
+ DebugJSON() ([]byte, error)
}
// AgentGitState holds the state necessary for pushing to a remote git repo
@@ -474,6 +475,11 @@
return a.config.Service.TokenContextWindow()
}
+// GetConvo returns the conversation interface for debugging purposes.
+func (a *Agent) GetConvo() ConvoInterface {
+ return a.convo
+}
+
// NewIterator implements CodingAgent.
func (a *Agent) NewIterator(ctx context.Context, nextMessageIdx int) MessageIterator {
a.mu.Lock()