Skip to content

feat(core) RequestRule#9489

Merged
dylan-hurd-oai merged 17 commits intomainfrom
dh--on-request-rule
Jan 28, 2026
Merged

feat(core) RequestRule#9489
dylan-hurd-oai merged 17 commits intomainfrom
dh--on-request-rule

Conversation

@dylan-hurd-oai
Copy link
Collaborator

@dylan-hurd-oai dylan-hurd-oai commented Jan 19, 2026

Summary

Instead of trying to derive the prefix_rule for a command mechanically, let's let the model decide for us.

Testing

  • tested locally
  • added tests

@dylan-hurd-oai dylan-hurd-oai changed the title feat(core) ApprovalPolicy:OnRequestRule feat(core) RequestRule Jan 27, 2026
@dylan-hurd-oai dylan-hurd-oai marked this pull request as ready for review January 27, 2026 19:22
@dylan-hurd-oai
Copy link
Collaborator Author

@codex review

Copy link
Contributor

@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: 7c819dfd7d

ℹ️ 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 on lines +423 to +427
{
return None;
}

Some(ExecPolicyAmendment::new(prefix_rule.clone()))
Copy link
Contributor

Choose a reason for hiding this comment

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

P1 Badge Validate prefix_rule against executed command

When RequestRule is enabled, prefix_rule from the tool call is turned into a persisted ExecPolicyAmendment without verifying that it is a prefix of any parsed command segment. In the case where a prompt-injected or buggy model supplies a broader or unrelated prefix (e.g. ['rm'] while running a benign command), the approval UI can present and persist a rule that grants escalation for commands the user did not intend to authorize. Consider rejecting or normalizing prefix_rule unless it is a prefix of the command being approved.

Useful? React with 👍 / 👎.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@codex update to validate prefix_rule against the command

Copy link
Contributor

Choose a reason for hiding this comment

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

Summary

Testing

  • cargo test -p codex-core (fails: default_client::tests::test_create_client_sets_default_headers; exec::tests::kill_child_process_group_kills_grandchildren_on_timeout; models_manager::manager::tests::{refresh_available_models_drops_removed_remote_models, refresh_available_models_refetches_when_cache_stale, refresh_available_models_sorts_by_priority, refresh_available_models_uses_cache_when_fresh}; shell_snapshot::tests::{linux_bash_snapshot_includes_sections, linux_sh_snapshot_includes_sections, timed_out_snapshot_shell_is_terminated, try_new_creates_and_deletes_snapshot_file}; unified_exec::tests::{multi_unified_exec_sessions, reusing_completed_process_returns_unknown_process, unified_exec_persists_across_requests})

View task →

let include_apply_patch_tool = features.enabled(Feature::ApplyPatchFreeform);
let include_collab_tools = features.enabled(Feature::Collab);
let include_collaboration_modes_tools = features.enabled(Feature::CollaborationModes);
let request_rule_enabled = features.enabled(Feature::RequestRule);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ideally, it would be nice to know at this point whether an enterprise has disallowed this via requirements.toml or some other mechanism. Perhaps we should support feature enablement in general in requirements.toml? /cc @gt-oai

Copy link
Collaborator Author

@dylan-hurd-oai dylan-hurd-oai Jan 27, 2026

Choose a reason for hiding this comment

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

I wonder if requirements.toml should instead just disallow changing exec policy? i.e. regardless of whether model suggests one or we derive it, requirements.toml should just be able to disable the "don't ask again" / persist behavior.

## prefix_rule guidance
When choosing a `prefix_rule`, request one that will allow you to fulfill similar requests from the user in the future without re-requesting escalation. It should be categorical and reasonably scoped to similar capabilities. You MUST NOT pass the entire command into `prefix_rule`.

<good_example reason="frequently run command">
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this be in triple backticks?

Some(lines.join("\n"))
}

fn render_command_prefix(prefix: &[String]) -> String {
Copy link
Collaborator

Choose a reason for hiding this comment

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

In practice, I wonder whether this could be large enough that we would consider it a problem?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah - @bolinfest given other discussions I'm going to avoid re-injecting the whole thing in every message, and we can set up different logic that adds it as a diff

@dylan-hurd-oai dylan-hurd-oai enabled auto-merge (squash) January 28, 2026 08:02
@dylan-hurd-oai dylan-hurd-oai merged commit 996e09c into main Jan 28, 2026
32 checks passed
@dylan-hurd-oai dylan-hurd-oai deleted the dh--on-request-rule branch January 28, 2026 08:43
@github-actions github-actions bot locked and limited conversation to collaborators Jan 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants