Skip to content

Preserve upstream context across intent chains#30

Merged
CoreyRDean merged 1 commit into
mainfrom
fix/intent-chain-context
May 14, 2026
Merged

Preserve upstream context across intent chains#30
CoreyRDean merged 1 commit into
mainfrom
fix/intent-chain-context

Conversation

@CoreyRDean
Copy link
Copy Markdown
Owner

Non-technical summary

This improves chained intent invocations 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

  • Extend the natural-language --json envelope emitted by internal/cli/intent.go to include the original prompt and current working directory alongside intent_response, exit_code, and captured stdout.
  • Teach downstream --from-intent prompt framing to unpack and surface that prompt/cwd context, which makes path-sensitive chaining less lossy.
  • Add regression coverage in internal/cli/intent_test.go for envelope unpacking and path-context preservation.
  • Extend the smoke test in internal/cli/smoke_test.go to assert the JSON envelope carries the original prompt and cwd.
  • Update README.md and docs/SPEC.md so the documented inter-intent contract matches the implementation.

Relevant intent:

Tests:

  • go test ./internal/cli/...
  • go test ./...

Breaking changes:

  • None intended. The inter-intent JSON envelope gains additive fields (prompt, cwd) and remains backward-compatible for existing consumers that only read intent_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.

@CoreyRDean CoreyRDean marked this pull request as ready for review May 14, 2026 17:44
@CoreyRDean CoreyRDean merged commit 92fd5fc into main May 14, 2026
8 checks passed
@CoreyRDean CoreyRDean deleted the fix/intent-chain-context branch May 14, 2026 17:44
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread internal/cli/intent.go
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 == "" {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant