Skip to content

exec: expose thread source in CLI and TypeScript SDK - #40155

Closed
pakrym-oai wants to merge 2 commits into
mainfrom
pakrym/exec-sdk-thread-source
Closed

exec: expose thread source in CLI and TypeScript SDK#40155
pakrym-oai wants to merge 2 commits into
mainfrom
pakrym/exec-sdk-thread-source

Conversation

@pakrym-oai

Copy link
Copy Markdown
Contributor

Why

codex exec currently classifies every new thread and fork as user, so integrations using the CLI or TypeScript SDK cannot attribute agent work to the feature that initiated it. The app-server protocol and Python SDK already support caller-supplied thread sources.

What changed

  • Add codex exec --thread-source <SOURCE> for new threads and forks, including flags supplied after the fork subcommand.
  • Add threadSource?: string to the TypeScript SDK's ThreadOptions and forward it when the SDK creates a thread.
  • Preserve the existing user default and keep resumed threads' persisted source unchanged.
  • Verify custom sources are persisted in rollout metadata and included in outgoing x-codex-turn-metadata independently of the existing originator override.
codex exec --thread-source automated_review "Review the current changes"
const thread = codex.startThread({ threadSource: "automated_review" });

Verification

  • just test -p codex-exec --lib (61 tests)
  • just test -p codex-exec --test all exec_fork_creates_distinct_threads_with_and_without_a_prompt
  • just test -p codex-exec --test all supports_originator_override
  • TypeScript SDK subprocess tests (14 tests), focused typechecking, and live SDK integration coverage for source attribution, resume behavior, and the existing originator header.

Documentation

Update the Codex CLI reference and TypeScript SDK documentation to cover --thread-source and ThreadOptions.threadSource.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-22T23:49:33.137668Z da2cd2e New commits
🔒 Security Review Completed 2026-08-22T23:50:50.294435Z da2cd2e New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Copy link
Copy Markdown
Contributor

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: 8daa0e3b54

ℹ️ 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 codex-rs/exec/src/cli_tests.rs Outdated

assert!(cli.ignore_user_config);
assert!(cli.ignore_rules);
assert_eq!(cli.thread_source, None);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Badge Test the effective thread-source default

This assertion only checks the statically implied absence of the optional clap field; it does not exercise the new run_main fallback that maps absence to ThreadSource::User, so a regression in the user-visible default would still pass. Replace it with behavioral coverage that starts a thread without the flag and verifies that its persisted or request source is user.

AGENTS.md reference: AGENTS.md:L29-L30

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant