fix(harness-server): export SLACK_CHANNEL/SLACK_THREAD_TS for codex tools#531
Open
cjustice wants to merge 1 commit into
Open
fix(harness-server): export SLACK_CHANNEL/SLACK_THREAD_TS for codex tools#531cjustice wants to merge 1 commit into
cjustice wants to merge 1 commit into
Conversation
02729f2 to
c3804ea
Compare
…ools The Rust codex blocks bridge spawned `codex app-server` before reading any input, so the per-turn `thread_key` never reached the agent's tool subprocesses as SLACK_CHANNEL/SLACK_THREAD_TS. `slack-upload` therefore aborted with "SLACK_CHANNEL not set" and the agent could not deliver files back into the originating Slack thread. The Python codex-app-wrapper derived these vars from the thread_key "before the app server first starts" (export_slack_thread_env); that behavior was dropped when the Rust harness replaced the wrapper in paradigmxyz#344. Restore it for the codex blocks path: defer the codex app-server spawn until the first user turn and, before spawning, parse the thread_key out of the blocks line and export SLACK_CHANNEL/SLACK_THREAD_TS so the child — and the tool subprocesses it runs — inherit them. Supports both `slack:<channel>:<ts>` (api-rs) and legacy `slack:<team>:<channel>:<ts>` shapes; no-op for non-Slack threads. The claude-code blocks path (run_blocks_app_server) has the same gap but is a separate generic codepath; left out of this focused fix. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
c3804ea to
93f9734
Compare
Contributor
Author
|
@akshaan — mind taking a look when convenient? Small harness-server fix to export |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
harness-server codex(blocks mode, the default) never setsSLACK_CHANNEL/SLACK_THREAD_TS, soslack-uploadaborts withSLACK_CHANNEL not setand the agent can't deliver files back into the Slack thread.The Python
codex-app-wrapperderived these from the per-turnthread_keybefore starting the app server (export_slack_thread_env). That was dropped when the Rust harness replaced the wrapper in #344. The Rust bridge also spawnscodex app-servereagerly, before reading any input — so the child (and the tools it spawns, which inherit its env) can't pick up vars set mid-stream.Fix (
crates/harness-server/src/codex.rs)codex app-serverspawn +initializeto the first user turn.thread_keyfrom the blocks line and exportSLACK_CHANNEL/SLACK_THREAD_TSso the child and its tool subprocesses inherit them. Mirrorsexport_slack_thread_env; supportsslack:<channel>:<thread_ts>(api-rs) and legacyslack:<team>:<channel>:<thread_ts>; no-op for non-Slack threads.env::set_varruns before the child/reader threads exist (single-threaded), so it's sound. Deferringinitializematches the wrapper's original ordering and is invisible to api-rs — no harness output flows until the first turn.Scope
Only the codex blocks path. The
claude-codepath (run_blocks_app_server) has the same gap — separate generic codepath, left for follow-up.Testing
slack_channel_and_thread/thread_key_from_blocks_line(arity, legacy 4-part keys, non-Slack, empty/blank/absent/invalid).codex app-serverrecords its inherited env; assertsSLACK_CHANNEL/SLACK_THREAD_TSare set fromthread_key "slack:C123:123.456". Confirmed to fail without the fix.cargo test(37 lib + 8 integration),cargo fmt --check,cargo clippyall clean. K8s E2E not run — change is confined to the harness binary.🤖 Generated with Claude Code