Skip to content

fix(cloud): keep git_signed_commit visible when GH token lands post-spawn#2313

Merged
VojtechBartos merged 1 commit into
mainfrom
vojtab/signed-commit-token-gate
May 22, 2026
Merged

fix(cloud): keep git_signed_commit visible when GH token lands post-spawn#2313
VojtechBartos merged 1 commit into
mainfrom
vojtab/signed-commit-token-gate

Conversation

@VojtechBartos
Copy link
Copy Markdown
Member

Summary

  • git_signed_commit was gated on ctx.token at session-creation time. If GH_TOKEN/GITHUB_TOKEN weren't in process.env at that exact moment (e.g. set by the orchestrator post-spawn, or only exported in a child shell init), the gate failed and the tool was filtered out of the in-process MCP server for the rest of the session — the agent reported "Waiting for the local PostHog MCP server… to finish connecting" and couldn't commit at all.
  • Drop the token check from isEnabled; resolve the token lazily inside the handler via resolveGithubToken(). The tool now stays visible in every cloud run, and if no token is found at call time it returns a clear error instead of silently disappearing.
  • Symptom thread: https://posthog.slack.com/archives/C06NZEZ7V3Q/p1779481230518509

Test plan

  • pnpm --filter @posthog/agent test — all 444 tests pass
  • pnpm --filter @posthog/agent typecheck clean
  • registry.test.ts: cloud-run-without-token now returns the tool (lazy resolve); desktop unchanged
  • Verify in a fresh cloud sandbox run that git_signed_commit appears in ToolSearch and commits succeed

Notes

This is the smaller of two possible fixes. The proper plumbing — the orchestrator POSTing fresh tokens into the agent server with a git credential helper — lives on ryan/add_env_propegation (commit 1d7baca5) and isn't merged yet. Shipping this now removes the user-visible "tool disappears" symptom; the bridge can land independently.

…pawn

The tool was gated on `ctx.token` at session-creation time, which captured
`process.env.GH_TOKEN`/`GITHUB_TOKEN` once. If the orchestrator (or a shell
init) set the token after the agent process started, the gate failed and the
tool was filtered out of the in-process MCP server for the rest of the
session — leaving the agent unable to commit at all.

Drop the token check from the gate and resolve the token lazily inside the
handler. The tool now stays visible in every cloud run; if no token is found
at call time it returns a clear error instead of silently disappearing.
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 22, 2026

Reviews (1): Last reviewed commit: "fix(cloud): keep git_signed_commit visib..." | Re-trigger Greptile

@tatoalo tatoalo added the Create Release This will trigger a new release label May 22, 2026
@VojtechBartos VojtechBartos enabled auto-merge (squash) May 22, 2026 20:51
@VojtechBartos VojtechBartos self-assigned this May 22, 2026
@VojtechBartos VojtechBartos merged commit 7ffc2fc into main May 22, 2026
15 checks passed
@VojtechBartos VojtechBartos deleted the vojtab/signed-commit-token-gate branch May 22, 2026 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Create Release This will trigger a new release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants