Skip to content

fix: OpenClaw native JSONL format support (multi-agent + toolCall parsing)#6

Open
Kyzcreig wants to merge 3 commits intoaeromomo:mainfrom
Kyzcreig:fix/observe-multi-agent
Open

fix: OpenClaw native JSONL format support (multi-agent + toolCall parsing)#6
Kyzcreig wants to merge 3 commits intoaeromomo:mainfrom
Kyzcreig:fix/observe-multi-agent

Conversation

@Kyzcreig
Copy link

@Kyzcreig Kyzcreig commented Mar 13, 2026

Bugs Fixed

1. observe processes 0 sessions in multi-agent setups

Root cause: sessions_dirs[0] picks the first agent alphabetically (e.g. anvil, claude-code) instead of the primary agent (main). Returns {"processed": 0, "total_tracked": 0} silently.

Fix: Collect *.jsonl files across all agent dirs with a single sorted generator.


2. All tool interactions extracted as unknown operation / Ran unknown

Root cause: The extractor assumed Anthropic API schema (tool_use blocks, toolName, input fields, role: tool results). OpenClaw's native JSONL format uses different names throughout:

What the parser expected What OpenClaw actually writes
content block type: "tool_use" type: "toolCall"
block.toolName block.name
block.input block.arguments
role: "tool" for results role: "toolResult"
result in content type: "toolResult" block result in content[0].text
no call id matching toolCallId field on result message

Fix: Rewrite extract_tool_interactions to handle OpenClaw's native format as primary, with legacy OpenAI-style tool_calls array as fallback. Match results to calls via toolCallId.

Impact

Tested on 202 real OpenClaw sessions across 4 agents:

Before: Every session → unknown operation / Ran unknown × N, useless observations

After:

  • 3,790,702 tokens → 114,447 tokens compressed (97.0% reduction)
  • Top session: 649,882 → 9,210 tokens (98.6%)
  • 0 failures across all 202 sessions
  • Accurate, readable observations (tool names, inputs, outputs, assistant reasoning)

Without this fix, every OpenClaw user running observe gets silently broken output — 99% compression ratio on garbage observations.

Forge added 2 commits March 13, 2026 10:30
sessions_dirs[0] picked the first agent alphabetically (e.g. 'anvil')
instead of the primary agent ('main'), causing observe to process 0
sessions in multi-agent setups.

Fix: collect session files across all agent dirs with a single sorted
generator. Tested: 192 sessions processed across 4 agents.
OpenClaw JSONL uses camelCase 'toolCall' content blocks (not Anthropic's
'tool_use'), with fields 'name'+'arguments' (not 'toolName'+'input').
Tool results are separate messages with role='toolResult' (not role='tool'),
carrying top-level 'toolCallId'+'toolName' and result in content[0].text.

Previous behavior: every tool interaction parsed as 'unknown operation /
Ran unknown' because field names never matched.

Fix:
- toolCall: read block.name and block.arguments (fall back to legacy fields)
- toolResult: match role='toolResult', extract content[0].text, pair by toolCallId
- Keep legacy OpenAI tool_calls array support for compatibility

Tested on 202 real OpenClaw sessions:
- Before fix: 0 interactions extracted per session
- After fix: 3,676,255 tokens compressed from 3,790,702 (97.0% reduction)
  Top session: 649K tokens → 9K (98.6%)
@Kyzcreig Kyzcreig changed the title fix: observe scans all agents, not just the first fix: OpenClaw native JSONL format support (multi-agent + toolCall parsing) Mar 13, 2026
The tiers command scores by keyword matching which produces low-signal
output when run against observations/ directories. Hand-curated L0/L1
files will be silently overwritten on next tiers run.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant