-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Summary
When the agent invokes tools during a conversation, there is no logging or user-visible feedback about which tools were called, what arguments were passed, or what results were returned. This makes it difficult to debug unexpected behavior, audit agent actions, and understand what's happening during longer multi-tool interactions.
Motivation
- Debugging: When the agent produces an unexpected result, there's no way to trace which tools it called or what arguments it used without inspecting PydanticAI internals.
- User feedback: In the REPL, the user sees only the streamed text response — tool calls happen silently. A brief indicator (e.g.,
⚙ send_cc(synth="minilogue-xd", parameter="cutoff", value=80)) would improve the interactive experience. - Audit trail: For patch management and MIDI operations, it's useful to have a record of what the agent actually did (e.g., which CCs were sent, which patches were saved/deleted).
Current behavior
- Tools are async functions registered on the PydanticAI
Agentinagent.py - The CLI loop in
cli.pyusesagent.run_stream()which handles tool dispatch internally - No
loggingmodule is used anywhere in the codebase - Errors are returned as plain strings from tool functions or printed via
rich.Console
Proposed behavior
- Add Python
loggingwith apatchworklogger hierarchy (e.g.,patchwork.tools.midi,patchwork.tools.patches) - Log tool calls at
INFOlevel with tool name and arguments when a tool is invoked - Log tool results at
DEBUGlevel with the return value - Log errors at
WARNING/ERRORlevel when tool execution fails - Surface tool use in the REPL — display a brief, styled indicator in the console when the agent calls a tool (before the streamed text response), so the user can see what's happening in real time
Implementation notes
- PydanticAI exposes message types like
ToolCallPartandToolReturnPartin the message history (result.all_messages()). These can be inspected after eachrun_stream()call, or the stream's message events can be consumed to show tool calls as they happen. - Consider a
--verbose/-vCLI flag to control whether tool-call indicators are shown in the REPL (default on for tool names, off for full args/results). - Log output should go to a file (e.g.,
data/patchwork.log) or stderr, not stdout, to avoid mixing with the streamed agent response.
References
- Agent definition:
patchwork/agent.py - CLI loop:
patchwork/cli.py - Tool modules:
patchwork/tools/midi_control.py,patchwork/tools/patches.py
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels