Repository navigation
feat: add Qwen Code parser - #70
RHL-RWT-01 wants to merge 1 commit into
Conversation
Qwen Code keeps each session in ~/.qwen/projects/<project>/chats/<session-id>.jsonl (override with AGENTPLAY_QWEN_HOMES). Records are uuid-linked ChatRecords whose messages carry Gemini-style `parts`: text, thoughts, functionCall and functionResponse. - Detection runs before the Claude Code and opencode rules, which both match Qwen records by shape. - Tool failures come from toolCallResult.status (error, cancelled); a call with no result stays unset. - Completion tokens are total - prompt when a total is recorded, so thoughts are not counted twice by OpenAI-compatible providers. - chat_compression system records count as compactions. - Subagent transcripts are not read (main lane only). Fixtures are two redacted real Qwen Code 0.26.5 sessions, one with failed tool calls. Closes Entelligence-AI#65
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
EntelligenceAI PR SummaryAdds Qwen Code session discovery and parsing, including turn and tool spans, tool results and failures, token usage, compactions, and tool-name aliases. Registers the new agent and documents its location and home-directory override, with fixtures and tests covering parsing, discovery, and map output. Review Scorecard
Safe to merge with a low blast radius; code quality rated Excellent (5/5): the review found nothing to flag. Key Findings:
Evaluated against
|
WalkthroughAdds end-to-end Qwen Code transcript support, from configurable local discovery and session indexing through parsing, tool normalization, and span generation. Documentation and tests cover transcript formats, tool workflows, usage metadata, compaction events, and malformed-input handling. ChangesFiles
Documents Qwen Code support, transcript locations, working-directory detection, and the Files
Adds Qwen record detection and exports a parser that converts JSONL sessions into shared session, turn, and tool spans. Parsing handles sidechains, duplicate UUIDs, tool results and failures, usage data, metadata, edit evidence, and compaction events. Files
Discovers Qwen session files under configured homes, extracts session IDs and working directories, and indexes valid transcripts while skipping invalid or unsuitable files. Dispatches indexed sessions to the Qwen parser. Files
Adds Qwen Code tool aliases that normalize built-in tool names to canonical names while leaving unlisted meta and MCP tools unchanged. Files
Adds transcript fixtures and coverage for parsing, detection, local discovery, tool workflows and failures, token accounting, compaction records, malformed input, privacy-safe maps, and tool alias mappings. |
Summary
Adds Qwen Code as a supported agent. Closes #65
parsers/qwen_code.py): reads the uuid-linked ChatRecords in~/.qwen/projects/<project>/chats/<session-id>.jsonl. User prompts open turns (mid-turn user messages join the running turn), assistantfunctionCallparts become tool spans, and results are matched bytoolCallResult.callId(falling back tofunctionResponse.id).statusoferror/cancelledmarks the tool failed, and a call with no result stays unset. Duplicate uuids keep the last copy, sidechain records are skipped, andchat_compressionrecords count as compactions.totalTokenCount - promptTokenCountwhen a total is recorded, so thoughts are not counted twice by OpenAI-compatible providers (which include them incandidatesTokenCount). Otherwise it is candidates + thoughts.tool_taxonomy.py): the 11 Qwen Code 0.26 tool names mapped to canonical tools (run_shell_command→ Bash,read_file→ Read,edit→ Edit,write_file→ Write,agent→ Task, …).~/.qwenhome, overridable withAGENTPLAY_QWEN_HOMES. Shows up inagentplay agents. The indexer skips sessions with no prompt or reply. README tables are updated.base.py): aqwen-coderule placed before the Claude Code and opencode rules, since both of those also match Qwen records by shape.Test plan
make check: ruff clean, pytest 1501 passed, viewer typecheck clean, vitest 354 passed,check_clean.pyclean.test_qwen_code_parser.py(44 tests): detection for every record type (Claude Code and opencode records are not claimed), turns and tools, every status value, missing results, mid-turn messages, sidechains, token math, compaction, malformed and empty input, discovery and env override, and no-leak tests on prompts, output, arguments and shell commands (verb only).failed_readhas two failed reads (invalid_tool_params).edit_then_readhas a failed write (edit_requires_prior_read) followed by a successful read. Tests check the classified events and that no placeholder text, path or file name reaches the map.~/.qwenwith a tempAGENTPLAY_HOME:agentplay agentslists qwen-code, andagentplay build --agents qwen-codebuilt 13 sessions (1 skipped, no events). Grepping the built maps for prompt text, replies, file contents, error messages and the home path found nothing.Not tested: none of the captured sessions ran a shell command, so the shell path (verb, exit code) is covered only by synthetic records. Subagent transcripts are not read (main lane only). Not run on Windows.
make checkpasses