Skip to content

Fix parser tool inference defaults - #75

Merged
TraderSamwise merged 2 commits into
masterfrom
test/chat-parser-next-snapshots
Jun 6, 2026
Merged

Fix parser tool inference defaults#75
TraderSamwise merged 2 commits into
masterfrom
test/chat-parser-next-snapshots

Conversation

@TraderSamwise

@TraderSamwise TraderSamwise commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • infer Codex or Claude parser mode from obvious transcript chrome when callers omit tool context
  • keep explicit non-unknown tool context authoritative
  • add fixture regressions for omitted-tool Codex suggestion and Claude prompt handling

Verification

  • vitest run src/agent-output-parser-fixtures.test.ts
  • eslint src/ --max-warnings=0
  • tsc --noEmit
  • yarn build
  • vitest run

Summary by CodeRabbit

  • New Features

    • The output parser now automatically detects which AI tool generated the output when not explicitly specified, using transcript markers to infer between available tools.
  • Tests

    • Added comprehensive test coverage for tool inference scenarios, verifying correct detection and handling across different tool contexts.

@vercel

vercel Bot commented Jun 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app Ready Ready Preview, Comment Jun 6, 2026 10:32am

@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown

Lost in the diff? Review this PR in Change Stack to follow the change map from intent to exact ranges.

Review Change Stack

Warning

Review limit reached

@TraderSamwise, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 25 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2024cc04-2ee0-4e31-805f-bcfcd7628a22

📥 Commits

Reviewing files that changed from the base of the PR and between 73b35e5 and 0643eae.

📒 Files selected for processing (2)
  • src/agent-output-parser-fixtures.test.ts
  • src/agent-output-parser.ts
📝 Walkthrough

Walkthrough

The PR adds automatic tool-type inference to the agent output parser. A new internal helper analyzes the raw transcript for Codex and Claude patterns, then parseAgentOutput uses that inference when caller context is missing. New test cases verify the inference correctly identifies each tool and preserves explicit tool context.

Changes

Tool Inference for Agent Output Parser

Layer / File(s) Summary
Tool inference helper and integration
src/agent-output-parser.ts
New inferAgentOutputTool(raw) helper detects OpenAI Codex and Claude Code transcript markers (shell permissions, context patterns) and returns "codex", "claude", or null. Updated parseAgentOutput to use inferred tool when options.tool is empty or "unknown".
Tool inference test coverage
src/agent-output-parser-fixtures.test.ts
New test suite exercises parseAgentOutput tool inference: verifies correct tool is inferred when caller omits context, asserts explicit tool context is preserved, and validates parsed block-type sequences and prompt absence checks match fixture expectations for codex and claude.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • TraderSamwise/aimux#72: Both PRs extend/consume the same getParserFixture-driven parser fixture test setup, with the main PR leveraging that harness to add tool-inference assertions for parseAgentOutput.
  • TraderSamwise/aimux#68: The main PR's new parseAgentOutput tool-inference logic feeds the inferred tool into the same agent-output-parser normalization pipeline, where PR #68 adjusts Codex-specific block classification at the tool-driven level.
  • TraderSamwise/aimux#74: Both PRs extend parsing and fixture test coverage around Codex vs Claude transcripts, so the main PR's tool-inference change is directly tied to the rendering behavior expected by the retrieved PR.

Poem

🐰 A parser that learns to see,
Codex or Claude from the transcripts free,
No hints required, the patterns speak clear,
Tool inference magic drawing near!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix parser tool inference defaults' accurately summarizes the main change: implementing tool inference logic for the parser when tool context is omitted, with fallback defaults.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/chat-parser-next-snapshots

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/agent-output-parser-fixtures.test.ts (1)

63-93: ⚡ Quick win

Add one mixed-marker regression to lock inference correctness.

These tests cover clean transcripts, but not a Claude transcript whose response text mentions “OpenAI Codex” (or vice versa). That case is exactly where keyword-based false positives can slip in.

Suggested test addition
 describe("agent output parser tool inference", () => {
@@
   it("infers Claude mode when callers omit tool context", () => {
     const fixture = getParserFixture("claude-real-prompt-that-matches-codex-suggestion");

     const parsed = parseAgentOutput(fixture.raw);

     expect(parsed.parser.tool).toBe("claude");
     expect(parsed.blocks.map((block) => block.type)).toEqual(fixture.expected.map((block) => block.type));
   });

+  it("does not switch to Codex when Claude transcript text mentions OpenAI Codex", () => {
+    const fixture = getParserFixture("claude-real-prompt-that-matches-codex-suggestion");
+    const raw = `${fixture.raw}\n\n⏺ I previously used OpenAI Codex for this workflow.`;
+
+    const parsed = parseAgentOutput(raw);
+
+    expect(parsed.parser.tool).toBe("claude");
+  });
+
   it("preserves explicit non-unknown tool context", () => {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/agent-output-parser-fixtures.test.ts` around lines 63 - 93, Add a
regression test that exercises parseAgentOutput on a transcript where the
speaker is Claude (or codex) but the response text contains the other tool's
name (e.g., a Claude transcript that mentions "OpenAI Codex"), to ensure
keyword-only detection doesn't flip parser.tool; create a new it(...) in the
same describe block (e.g., "does not misinfer tool when response mentions the
other tool") that loads a fixture via getParserFixture (a new mixed-marker
fixture like "claude-with-codex-mention"), calls parseAgentOutput(fixture.raw)
and asserts parsed.parser.tool is the expected tool (and optionally that block
types match fixture.expected) to lock inference correctness.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/agent-output-parser.ts`:
- Around line 50-63: The current inferAgentOutputTool function (variables
hasCodexChrome and hasClaudeChrome) matches "OpenAI Codex"/"Claude Code"
anywhere in the transcript, so free-text mentions flip the inferred tool;
tighten the detection by changing those regexes to only match UI chrome/header
occurrences (anchor to start-of-text or start-of-line with optional whitespace
and require header/chrome punctuation or separators such as ":" "|" "—" or
parentheses or other UI chrome markers) instead of arbitrary inline mentions;
update the hasCodexChrome/hasClaudeChrome checks in inferAgentOutputTool to use
those anchored/header-aware patterns so casual conversation no longer triggers
codex/claude inference.

---

Nitpick comments:
In `@src/agent-output-parser-fixtures.test.ts`:
- Around line 63-93: Add a regression test that exercises parseAgentOutput on a
transcript where the speaker is Claude (or codex) but the response text contains
the other tool's name (e.g., a Claude transcript that mentions "OpenAI Codex"),
to ensure keyword-only detection doesn't flip parser.tool; create a new it(...)
in the same describe block (e.g., "does not misinfer tool when response mentions
the other tool") that loads a fixture via getParserFixture (a new mixed-marker
fixture like "claude-with-codex-mention"), calls parseAgentOutput(fixture.raw)
and asserts parsed.parser.tool is the expected tool (and optionally that block
types match fixture.expected) to lock inference correctness.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e83432fe-db00-4415-9b75-5055fbe18645

📥 Commits

Reviewing files that changed from the base of the PR and between fd9dbf4 and 73b35e5.

📒 Files selected for processing (2)
  • src/agent-output-parser-fixtures.test.ts
  • src/agent-output-parser.ts

Comment thread src/agent-output-parser.ts
@TraderSamwise
TraderSamwise merged commit b52fd74 into master Jun 6, 2026
3 checks passed
@TraderSamwise
TraderSamwise deleted the test/chat-parser-next-snapshots branch June 6, 2026 10:33
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