Skip to content

feat(agent): instruction-level rtk adoption for codex sessions#3491

Merged
trunk-io[bot] merged 1 commit into
mainfrom
posthog-code/rtk-guidance-for-codex
Jul 16, 2026
Merged

feat(agent): instruction-level rtk adoption for codex sessions#3491
trunk-io[bot] merged 1 commit into
mainfrom
posthog-code/rtk-guidance-for-codex

Conversation

@tatoalo

@tatoalo tatoalo commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Problem

rtk only works on Claude cloud runs today: the Claude adapter rewrites eligible Bash commands through it deterministically with an in-SDK PreToolUse hook. The Codex app-server protocol has no command-rewrite channel (native gap).

Codex cloud runs should get the same command-output token savings as Claude runs and since Codex can't be hooked deterministically, the instruction channel is the integration point it reliably reads.

Changes

  • add adapters/rtk-guidance.ts to generate RTK guidance for Codex, matching the Claude hook's supported command set and eligibility rules so behavior stays consistent across adapters

  • append the guidance in buildCodexInstructions, gated by resolveRtkPrefix so per-run RTK opt-outs also disable the instructions

  • export the shared RTK command sets from claude/session/rtk.ts to keep the guidance and hook in sync

@trunk-io

trunk-io Bot commented Jul 16, 2026

Copy link
Copy Markdown

😎 Merged successfully - details.

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 2bcea32.

@greptile-apps

greptile-apps Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "feat(agent): instruction-level rtk adopt..." | Re-trigger Greptile

Comment thread packages/agent/src/adapters/rtk-guidance.ts Outdated
Comment thread packages/agent/src/server/agent-server.ts
The Claude adapter routes eligible commands through rtk deterministically via a PreToolUse hook, but the Codex app-server protocol has no command-rewrite channel, so cloud Codex runs never used the rtk binary installed in the sandbox. Append rtk usage guidance to the Codex developer instructions instead, mirroring the Claude hook's eligibility sets and gated on resolveRtkPrefix so the per-run POSTHOG_RTK=0 kill switch also disables it.

Generated-By: PostHog Code
Task-Id: b005dede-2677-4364-94a2-c2a7e90e376a
@tatoalo
tatoalo force-pushed the posthog-code/rtk-guidance-for-codex branch from 25a6909 to 2bcea32 Compare July 16, 2026 10:06
@tatoalo tatoalo self-assigned this Jul 16, 2026
@tatoalo tatoalo added the Stamphog This will request an autostamp by stamphog on small changes label Jul 16, 2026

@stamphog stamphog 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.

No human teammate has reviewed the current head of this PR — the only current-head comments are the author's own replies to a bot. This is a behavioral change to how Codex agent instructions are built, which warrants at least one human sign-off before auto-approval.

@stamphog stamphog Bot removed the Stamphog This will request an autostamp by stamphog on small changes label Jul 16, 2026
@tatoalo
tatoalo enabled auto-merge (squash) July 16, 2026 15:14
@trunk-io
trunk-io Bot merged commit 7339159 into main Jul 16, 2026
37 checks passed
@trunk-io
trunk-io Bot deleted the posthog-code/rtk-guidance-for-codex branch July 16, 2026 15:30
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.

2 participants