Preserve upstream context across intent chains#30
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8a87655a34
ℹ️ 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".
| return "", false | ||
| } | ||
| if env.IntentResponse == nil && env.ExitCode == nil && env.Stdout == nil { | ||
| if env.IntentResponse == nil && env.ExitCode == nil && env.Stdout == nil && env.Prompt == "" && env.Cwd == "" { |
There was a problem hiding this comment.
Tighten envelope detection to avoid misclassifying JSON stdin
The new envelope check now treats any --from-intent JSON payload containing just prompt or cwd as an intent envelope, which is a regression from the previous behavior that required intent_response, exit_code, or stdout. In practice, if a user manually uses --from-intent with arbitrary JSON (or pipes tool output that includes a prompt field), we will summarize only a few fields and drop the rest of the payload from model context, changing command generation behavior unexpectedly.
Useful? React with 👍 / 👎.
Non-technical summary
This improves chained
intentinvocations so the downstream step keeps the upstream request context instead of only seeing bare stdout. That matters most when the upstream output is abbreviated, such as filenames without full paths, because follow-up requests can now retain the original target directory.Technical summary
--jsonenvelope emitted byinternal/cli/intent.goto include the original prompt and current working directory alongsideintent_response,exit_code, and captured stdout.--from-intentprompt framing to unpack and surface that prompt/cwd context, which makes path-sensitive chaining less lossy.internal/cli/intent_test.gofor envelope unpacking and path-context preservation.internal/cli/smoke_test.goto assert the JSON envelope carries the original prompt and cwd.README.mdanddocs/SPEC.mdso the documented inter-intent contract matches the implementation.Relevant intent:
INTENT.md's composability promise says chainedintentinvocations should preserve meaning.Tests:
go test ./internal/cli/...go test ./...Breaking changes:
prompt,cwd) and remains backward-compatible for existing consumers that only readintent_response/stdout/exit_code.Additional notes
Trade-off: this is a narrow transport-context fix, not a broader model-prompt redesign for all file/path reasoning.
Deferred follow-up: if chaining still drops intent in harder cases, the next slice should be prompt-level guidance or richer structured path hints rather than widening this envelope further without evidence.
Remaining gap: downstream reasoning still depends on the model using the preserved prompt/cwd well; this change removes a concrete information loss in the transport layer.