Skip to content

Fix Inngest agent routing#223

Merged
Jackson57279 merged 1 commit intomasterfrom
codex/fix-inngest-agent-routing
Apr 26, 2026
Merged

Fix Inngest agent routing#223
Jackson57279 merged 1 commit intomasterfrom
codex/fix-inngest-agent-routing

Conversation

@Jackson57279
Copy link
Copy Markdown
Collaborator

@Jackson57279 Jackson57279 commented Apr 26, 2026

Summary by cubic

Fixes Inngest coding agent routing to use stable tool-calling models and a deterministic retry chain, improving AgentKit reliability and failover behavior.
Centralizes model selection logic and adds better error reporting and metadata for debugging.

  • Bug Fixes

    • Normalize tool-calling model (strip :nitro) and fallback from unreliable tool models to a safe default.
    • Replace OpenRouter implicit fallbacks with an explicit retry chain; retry only on provider errors.
    • Persist agent failures to Convex with requested model, tool-calling model, retry chain, and error details.
  • Refactors

    • Extract model planning to src/inngest/model-routing.ts with resolveCodingModelPlan and getToolCallingModelForAgent.
    • Add unit tests for routing behavior in tests/inngest-model-routing.test.ts.
    • Include manager model, retry chain, and attempt count in fragment metadata for better observability.

Written for commit 1215e9d. Summary will update on new commits.

@vidoc-ai-security-engineer
Copy link
Copy Markdown

vidoc-ai-security-engineer Bot commented Apr 26, 2026

Vidoc Security Report

Great! No high-severity issues detected.

Details { "scanId": "019dc876-2f94-7087-acca-ee7e9a54cf92", "codebaseId": "019d74e8-a953-70b7-a19d-914ab632ae39", "installationId": "019d74e8-a4a8-772f-bdb7-b896739e2b23", "internalPullRequestId": "019dc876-2f79-7468-824f-00949d36f395" }

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 26, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Model routing logic is extracted from functions.ts into a new centralized model-routing.ts module that defines fallback chains, classifies models as reliable/unreliable, and exports functions to resolve tool-calling models and comprehensive coding model plans including manager models and retry sequences.

Changes

Cohort / File(s) Summary
Model Routing Module
src/inngest/model-routing.ts
New module introducing getToolCallingModelForAgent, resolveCodingModelPlan, and CODING_FALLBACK_CHAIN constant. Classifies models as unreliable for AgentKit tools, determines manager model eligibility, and builds deduplicated retry model sequences.
Functions Integration
src/inngest/functions.ts
Refactors coding-agent model selection to use resolveCodingModelPlan instead of getToolCallingModelForAgent. Removes openrouterAgentModel fallback chain construction, updates fallback orchestration to accept explicit retry lists, augments run results with managerModel, attemptedModels, and attemptCount, adds persistAgentFailure function for failed fragments, and removes tool_choice: "required" from agent configuration.
Model Routing Tests
tests/inngest-model-routing.test.ts
New Jest test suite validating :nitro suffix stripping, dedicated manager model selection for unstable tools, and deterministic retry model sequencing.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Hops through models with purpose clear,
Fallback chains standing ever near,
From functions wide to routing tight,
The agent picks its tools just right.
No more scattered, now aligned—
A cleaner path through code designed! 🌱

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix Inngest agent routing' directly and clearly describes the main change - refactoring the agent model selection and fallback logic into a centralized routing module.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-inngest-agent-routing

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@Jackson57279 Jackson57279 merged commit 013fa1e into master Apr 26, 2026
11 of 16 checks passed
@Jackson57279 Jackson57279 deleted the codex/fix-inngest-agent-routing branch April 26, 2026 06:27
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1215e9d5e6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/inngest/functions.ts
Comment on lines 496 to 499
name: "code-agent",
description: "An expert coding agent",
system: codeSystem,
tool_choice: "required",
model: openrouterAgentModel(
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Require tool calls in coding agent configuration

The coding agent is now created with the default tool_choice behavior (auto), so it can legally return a plain <task_summary> without invoking createOrUpdateFiles. In this workflow, the router stops once a summary is present and the run is treated as successful, which can produce “completed” fragments with no code changes. Restoring tool_choice: "required" (or an equivalent guard) is needed to preserve the prior guarantee that code-writing tasks actually execute tool calls.

Useful? React with 👍 / 👎.

Comment thread src/inngest/functions.ts
Comment on lines +891 to 892
model: openrouterAgentModel("anthropic/claude-haiku-4.5"),
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve fallback for post-processing model calls

Both post-processing agents now call anthropic/claude-haiku-4.5 without any fallback chain, so a transient provider outage/rate-limit in title or response generation causes the whole job to fail after coding has already completed. Previously these steps had fallback routing; removing it regresses reliability for users in the exact failure mode this patch is trying to address.

Useful? React with 👍 / 👎.

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