Resolve the workitems session from the running harness - #944
Conversation
KCAP_SESSION_ID reaches only Claude Code's Bash tool calls; the MCP server process carries CLAUDE_CODE_SESSION_ID and nothing else, or a parent shell's stale export. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
PR Summary by QodoResolve work-item sessions from the running harness
AI Description
Diagram
High-Level Assessment
Files changed (6)
|
Code Review by Qodo
1.
|
Closes #942 — AI-2780
What & why
Every kcap-workitems tool call that omitted
session_idfailed inside a hooked Claude Code session with an error telling the user to run inside a hooked session.KCAP_SESSION_IDis exported by the SessionStart hook into the file Claude Code applies to Bash tool calls only, so the MCP server process never has it; and when it is present it came from whichever shell launched the harness, naming the parent session. The workitems server now resolves an omittedsession_idthroughHarnessRequesterContext, as the flows server does: the running harness'sCLAUDE_CODE_SESSION_IDwins, with the ambientKCAP_SESSION_ID/CODEX_THREAD_IDlookup kept as the fallback. Tool descriptions, the error text, README and the work-items skill stop promising aKCAP_SESSION_IDdefault.Where to look
The session-resolution tests now inject the environment instead of setting it on the process. The suite itself runs under a harness that exports
CLAUDE_CODE_SESSION_ID, so the "neither present" case could only be pinned by injection.Verification
Live repro on a running
kcap mcp workitemsprocess (ps -E):CLAUDE_CODE_SESSION_IDandCLAUDE_PROJECT_DIRpresent,KCAP_SESSION_IDabsent;get_session_work_itemswith no argument returned the "No session id" error.New tests first failed on the old lookup (
Resolve_session_id_falls_back_to_the_running_harness_session: ArgumentException;…prefers_the_running_harness_session_over_an_inherited_env_var: got the inherited id), then:🤖 Generated with Claude Code