Skip to content

fix(agents): accept root writer tokens with integration grants - #4496

Merged
kwakayama merged 3 commits into
mainfrom
fix/demo-auth-root-writer-token
Sep 14, 2026
Merged

kwakayama merged 3 commits into
mainfrom
fix/demo-auth-root-writer-token

Conversation

@kwakayama

@kwakayama kwakayama commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Default chat fails before executing any tool when its valid integration grant makes the root run-event writer token larger than 4 KiB. A staging project with Gmail, Outlook and ServiceNow produced a 4,657-byte token and failed with Unable to initialize durable child event persistence.

Allow up to 32 KiB for the verified root writer credential, which carries integration grants. Keep child-token exchange at 4 KiB and its response body at 16 KiB. No token scopes or authorization checks change.

Related: https://github.com/veryfront/veryfront-issue-inbox/issues/1358#issuecomment-5660218175

Validation:

  • Red: the 4,657-byte root-token regression failed with the exact staging error; 23 existing tests passed.
  • Green: 27 tests / 48 steps across writer-token, durable-chat start, and durable-child execution suites.
  • Root oversize rejection and stricter child-token rejection remain covered.
  • Deno typecheck/lint and local uncommitted review passed.

The API grant/tool/auth-park fix is already deployed. After this framework change publishes, the Agent pin and deployed attachment acceptance retest will follow; issue closure waits for that evidence.

Summary by CodeRabbit

  • New Features

    • Increased the maximum supported size for root run event-writer tokens to 32 KiB.
    • Continued enforcing the existing 4 KiB limit for child tokens.
  • Tests

    • Added coverage confirming acceptance of root tokens up to the new limit.
    • Updated validation coverage to verify that tokens exceeding 32 KiB are rejected.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@greptile-apps greptile-apps 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.

Your trial has ended. Reactivate Greptile to resume code reviews.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-14T07:26:45.934284Z 064b411 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

Warning

Review limit reached

Next included review available in 39 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 1c5fa0ec-1121-46d6-934f-c07761ddf8d6

📥 Commits

Reviewing files that changed from the base of the PR and between 011838f and 064b411.

📒 Files selected for processing (7)
  • src/agent/conversation/run-event-limits.ts
  • src/agent/hosted/child-run-event-writer-token.test.ts
  • src/agent/hosted/child-run-event-writer-token.ts
  • src/agent/service/broker-ingress.test.ts
  • src/agent/service/broker-ingress.ts
  • src/internal-agents/provider-replay-checkpoint-persister.test.ts
  • src/internal-agents/provider-replay-checkpoint-persister.ts

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: fe8f4394-2187-40fb-b27f-0adbfaea4eca

📥 Commits

Reviewing files that changed from the base of the PR and between f105ec1 and 011838f.

📒 Files selected for processing (2)
  • src/agent/hosted/child-run-event-writer-token.test.ts
  • src/agent/hosted/child-run-event-writer-token.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Root run event-writer tokens now allow up to 32 KiB. Child tokens retain the 4 KiB limit. Tests cover a 4,657-character root token and rejection above 32 KiB.

Changes

Root token validation

Layer / File(s) Summary
Configurable token limits and boundary tests
src/agent/hosted/child-run-event-writer-token.ts, src/agent/hosted/child-run-event-writer-token.test.ts
Token validation accepts a configurable byte limit. Root capability creation uses the 32 KiB limit, while child-token validation retains the 4 KiB limit. Tests cover acceptance at 4,657 characters and rejection above 32 KiB.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 01183

The root-token limit is enforced at 32 KiB while child tokens remain limited to 4 KiB, with no unresolved merge-blocking risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. 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 clearly describes the main change: accepting root writer tokens that contain integration grants.
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.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/demo-auth-root-writer-token

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.

@github-actions

Copy link
Copy Markdown

📦 Client bundle boundary

Entrypoint Modules Source size Server leaks
src/index.client.ts 289 2307 KiB ✅ 0

A server module in a client graph aborts hydration in the browser. New leaks fail CI; known leaks are tracked in scripts/lint/client-bundle-baseline.json to burn down.

@gitar-bot

gitar-bot Bot commented Sep 14, 2026

Copy link
Copy Markdown

Gitar is working

Gitar

@kwakayama kwakayama left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Review score: 88/100 — good, minor suggestions

Focused, well-tested bug fix for a real production regression (4,657-byte root token rejected at the old 4 KiB cap).

Strengths:

  • Root cause is clear and the fix is narrowly scoped: only the root writer-token check (createHostedRunEventWriterCapability) gets the raised 32 KiB ceiling. I traced parseRunEventToken (used for the child-token exchange response) and confirmed it still calls isValidRunEventWriterToken(token) with the default 4 KiB limit — no accidental widening of the child path.
  • Test changes are precise: the old oversize-rejection test now asserts on the correct new boundary (32 * 1024 + 1) instead of the stale 5_000, and a new test locks in the real-world 4,657-byte payload from the staging regression.
  • PR description is exemplary — includes the exact error, a red/green validation summary, and a link to the tracking issue.
  • No auth/scope semantics changed, just a size ceiling — low blast radius.
  • Inline comment on the new constant explains why 32 KiB (integration grants), not just what.

Minor suggestions (non-blocking):

  • No test asserts acceptance exactly at the new 32 KiB boundary (only well under it at 4,657 bytes, and rejection at 32 KiB + 1). Worth adding for symmetry with the existing boundary-style tests in this file.
  • 32 KiB is still a fixed magic number chosen to cover the observed worst case (Gmail+Outlook+ServiceNow grants) rather than derived from a hard upper bound on integration-grant size — fine for now, but if the number of default integrations grows this could need revisiting again. Not a blocker.
  • PR description notes the API-side fix is "already deployed" and issue closure is pending a retest — worth double-checking CI finishes green and the linked issue is updated once this merges.

No security or design concerns beyond the note above.


Generated by Claude Code

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 011838f6d2

ℹ️ 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/agent/hosted/child-run-event-writer-token.ts Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@greptile-apps greptile-apps 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.

Your trial has ended. Reactivate Greptile to resume code reviews.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e6a4891e13

ℹ️ 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/agent/conversation/run-event-limits.ts
@codecov

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@greptile-apps greptile-apps 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.

Your trial has ended. Reactivate Greptile to resume code reviews.

@sonarqubecloud

Copy link
Copy Markdown

@kwakayama
kwakayama added this pull request to the merge queue Sep 14, 2026
Merged via the queue into main with commit 93a7f33 Sep 14, 2026
60 checks passed
@kwakayama
kwakayama deleted the fix/demo-auth-root-writer-token branch September 14, 2026 08:02
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