Debugging
Capture raw prompts, responses, and troubleshoot issues.
Quick Debug with Presets
Section titled “Quick Debug with Presets”import { HookPresets } from 'llmist';
// Full monitoring.withHooks(HookPresets.monitoring({ verbose: true }))
// Specific debugging.withHooks(HookPresets.logging({ verbose: true })).withHooks(HookPresets.errorLogging()).withHooks(HookPresets.timing())| Symptom | Recommended Preset |
|---|---|
| Agent not responding | monitoring() |
| Unexpected behavior | logging({ verbose: true }) |
| High costs | tokenTracking() |
| Errors/crashes | errorLogging() |
| Slow performance | timing() |
Capture Raw Requests
Section titled “Capture Raw Requests”.withHooks({ observers: { onLLMCallStart: async (ctx) => { console.log('Model:', ctx.options.model); console.log('Messages:', ctx.options.messages); }, onLLMCallComplete: async (ctx) => { console.log('Response:', ctx.rawResponse); console.log('Tokens:', ctx.usage); }, },})Debug Gadget Execution
Section titled “Debug Gadget Execution”.withHooks({ observers: { onGadgetExecutionStart: async (ctx) => { console.log(`[${ctx.gadgetName}] Starting`); console.log('Parameters:', ctx.parameters); }, onGadgetExecutionComplete: async (ctx) => { console.log(`[${ctx.gadgetName}] ${ctx.executionTimeMs}ms`); if (ctx.error) console.error('Error:', ctx.error); }, },})Custom Logger
Section titled “Custom Logger”For detailed logger configuration, see Logging Reference.
import { createLogger } from 'llmist';
const logger = createLogger({ minLevel: 'debug' });.withLogger(logger)CLI Debugging
Section titled “CLI Debugging”bunx @llmist/cli complete "test" --model haiku 2>&1 | tee debug.logbunx @llmist/cli agent "test" --gadget ./tool.ts 2>&1npx @llmist/cli complete "test" --model haiku 2>&1 | tee debug.lognpx @llmist/cli agent "test" --gadget ./tool.ts 2>&1See Also
Section titled “See Also”- Hooks Guide - All hook types
- Troubleshooting - Common issues