fix: OpenClaw native JSONL format support (multi-agent + toolCall parsing)#6
Open
Kyzcreig wants to merge 3 commits intoaeromomo:mainfrom
Open
fix: OpenClaw native JSONL format support (multi-agent + toolCall parsing)#6Kyzcreig wants to merge 3 commits intoaeromomo:mainfrom
Kyzcreig wants to merge 3 commits intoaeromomo:mainfrom
Conversation
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%)
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bugs Fixed
1.
observeprocesses 0 sessions in multi-agent setupsRoot 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
*.jsonlfiles across all agent dirs with a single sorted generator.2. All tool interactions extracted as
unknown operation / Ran unknownRoot cause: The extractor assumed Anthropic API schema (
tool_useblocks,toolName,inputfields,role: toolresults). OpenClaw's native JSONL format uses different names throughout:type: "tool_use"type: "toolCall"block.toolNameblock.nameblock.inputblock.argumentsrole: "tool"for resultsrole: "toolResult"type: "toolResult"blockcontent[0].texttoolCallIdfield on result messageFix: Rewrite
extract_tool_interactionsto handle OpenClaw's native format as primary, with legacy OpenAI-styletool_callsarray as fallback. Match results to calls viatoolCallId.Impact
Tested on 202 real OpenClaw sessions across 4 agents:
Before: Every session →
unknown operation / Ran unknown× N, useless observationsAfter:
Without this fix, every OpenClaw user running
observegets silently broken output — 99% compression ratio on garbage observations.