Skip to content

Move string truncation helpers into codex-utils-string#15572

Merged
aibrahim-oai merged 3 commits intomainfrom
codex/extract-string-truncation-utils
Mar 24, 2026
Merged

Move string truncation helpers into codex-utils-string#15572
aibrahim-oai merged 3 commits intomainfrom
codex/extract-string-truncation-utils

Conversation

@aibrahim-oai
Copy link
Copy Markdown
Collaborator

  • move the shared byte-based middle truncation logic from core into codex-utils-string
  • keep token-specific truncation in codex-core so rollout can reuse the shared helper in the next stacked PR

@aibrahim-oai aibrahim-oai force-pushed the codex/extract-git-utils-crate branch from 56b3e16 to 12948a4 Compare March 23, 2026 23:34
@aibrahim-oai aibrahim-oai force-pushed the codex/extract-string-truncation-utils branch 2 times, most recently from c62c328 to 5ed93d4 Compare March 23, 2026 23:37
aibrahim-oai added a commit that referenced this pull request Mar 24, 2026
Co-authored-by: Codex <noreply@openai.com>
aibrahim-oai added a commit that referenced this pull request Mar 24, 2026
Co-authored-by: Codex <noreply@openai.com>
@aibrahim-oai aibrahim-oai force-pushed the codex/extract-string-truncation-utils branch from 9401d05 to b8a17ba Compare March 24, 2026 00:16
aibrahim-oai added a commit that referenced this pull request Mar 24, 2026
Co-authored-by: Codex <noreply@openai.com>
@aibrahim-oai aibrahim-oai force-pushed the codex/extract-string-truncation-utils branch from b8a17ba to a28046a Compare March 24, 2026 00:22
aibrahim-oai added a commit that referenced this pull request Mar 24, 2026
Co-authored-by: Codex <noreply@openai.com>
@aibrahim-oai aibrahim-oai force-pushed the codex/extract-string-truncation-utils branch from a28046a to 9e2a887 Compare March 24, 2026 00:34
@aibrahim-oai aibrahim-oai force-pushed the codex/extract-string-truncation-utils branch from 9e2a887 to 8aca7f8 Compare March 24, 2026 01:47
aibrahim-oai added a commit that referenced this pull request Mar 24, 2026
Co-authored-by: Codex <noreply@openai.com>
aibrahim-oai added a commit that referenced this pull request Mar 24, 2026
Co-authored-by: Codex <noreply@openai.com>
@aibrahim-oai aibrahim-oai force-pushed the codex/extract-string-truncation-utils branch from 8aca7f8 to fda1492 Compare March 24, 2026 02:05
aibrahim-oai added a commit that referenced this pull request Mar 24, 2026
Co-authored-by: Codex <noreply@openai.com>
@aibrahim-oai aibrahim-oai force-pushed the codex/extract-string-truncation-utils branch from fda1492 to 4bf0fbc Compare March 24, 2026 02:13
aibrahim-oai added a commit that referenced this pull request Mar 24, 2026
Co-authored-by: Codex <noreply@openai.com>
@aibrahim-oai aibrahim-oai force-pushed the codex/extract-string-truncation-utils branch from 4bf0fbc to 8a0da2e Compare March 24, 2026 02:24
aibrahim-oai added a commit that referenced this pull request Mar 24, 2026
Co-authored-by: Codex <noreply@openai.com>
@aibrahim-oai aibrahim-oai force-pushed the codex/extract-string-truncation-utils branch from 8a0da2e to e66ce7d Compare March 24, 2026 02:29
@aibrahim-oai
Copy link
Copy Markdown
Collaborator Author

@codex review this

1 similar comment
@aibrahim-oai
Copy link
Copy Markdown
Collaborator Author

@codex review this

@chatgpt-codex-connector
Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Keep them coming!

ℹ️ 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".

aibrahim-oai added a commit that referenced this pull request Mar 24, 2026
Co-authored-by: Codex <noreply@openai.com>
@aibrahim-oai aibrahim-oai force-pushed the codex/extract-string-truncation-utils branch from e66ce7d to 56f37f8 Compare March 24, 2026 03:16
aibrahim-oai added a commit that referenced this pull request Mar 24, 2026
Co-authored-by: Codex <noreply@openai.com>
@aibrahim-oai aibrahim-oai force-pushed the codex/extract-string-truncation-utils branch from 56f37f8 to 333051d Compare March 24, 2026 03:18
@aibrahim-oai
Copy link
Copy Markdown
Collaborator Author

@codex review this

Copy link
Copy Markdown
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: 333051d7bc

ℹ️ 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/utils/string/src/truncate.rs Outdated
Some(MiddleTruncation {
prefix,
suffix,
removed_bytes: s.len().saturating_sub(max_bytes),
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.

P2 Badge Derive removed_bytes from retained slices, not budget

removed_bytes is set to s.len() - max_bytes, but UTF-8 boundary preservation can retain fewer than max_bytes bytes. This undercounts removals for multibyte text (e.g. 4 emojis with max_bytes=14 removes 8 bytes but reports 2). truncate_middle_with_token_budget then underreports removed_tokens because it relies on this field. Compute removals from prefix.len() and suffix.len() instead.

Useful? React with 👍 / 👎.

@aibrahim-oai aibrahim-oai force-pushed the codex/extract-string-truncation-utils branch from 3b6fddc to 918fbba Compare March 24, 2026 14:57
aibrahim-oai added a commit that referenced this pull request Mar 24, 2026
Co-authored-by: Codex <noreply@openai.com>
aibrahim-oai added a commit that referenced this pull request Mar 24, 2026
Co-authored-by: Codex <noreply@openai.com>
aibrahim-oai added a commit that referenced this pull request Mar 24, 2026
Co-authored-by: Codex <noreply@openai.com>
aibrahim-oai added a commit that referenced this pull request Mar 24, 2026
Co-authored-by: Codex <noreply@openai.com>
aibrahim-oai added a commit that referenced this pull request Mar 24, 2026
Co-authored-by: Codex <noreply@openai.com>
aibrahim-oai added a commit that referenced this pull request Mar 24, 2026
Co-authored-by: Codex <noreply@openai.com>
aibrahim-oai added a commit that referenced this pull request Mar 24, 2026
Co-authored-by: Codex <noreply@openai.com>
aibrahim-oai added a commit that referenced this pull request Mar 24, 2026
Co-authored-by: Codex <noreply@openai.com>
aibrahim-oai added a commit that referenced this pull request Mar 24, 2026
Co-authored-by: Codex <noreply@openai.com>
aibrahim-oai added a commit that referenced this pull request Mar 24, 2026
Co-authored-by: Codex <noreply@openai.com>
aibrahim-oai added a commit that referenced this pull request Mar 24, 2026
Co-authored-by: Codex <noreply@openai.com>
aibrahim-oai added a commit that referenced this pull request Mar 24, 2026
Co-authored-by: Codex <noreply@openai.com>
aibrahim-oai added a commit that referenced this pull request Mar 24, 2026
Co-authored-by: Codex <noreply@openai.com>
aibrahim-oai added a commit that referenced this pull request Mar 24, 2026
Co-authored-by: Codex <noreply@openai.com>
aibrahim-oai added a commit that referenced this pull request Mar 24, 2026
Co-authored-by: Codex <noreply@openai.com>
@aibrahim-oai
Copy link
Copy Markdown
Collaborator Author

@codex review this

Copy link
Copy Markdown
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: 918fbba026

ℹ️ 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/protocol/src/output_truncation.rs Outdated
aibrahim-oai added a commit that referenced this pull request Mar 24, 2026
Co-authored-by: Codex <noreply@openai.com>
@aibrahim-oai
Copy link
Copy Markdown
Collaborator Author

@review and make sure no behavioral changes.

Base automatically changed from codex/extract-git-utils-crate to main March 24, 2026 20:26
@aibrahim-oai aibrahim-oai force-pushed the codex/extract-string-truncation-utils branch from cf6ff4f to eae882e Compare March 24, 2026 21:22
Co-authored-by: Codex <noreply@openai.com>
@aibrahim-oai aibrahim-oai force-pushed the codex/extract-string-truncation-utils branch from 7ea10d9 to 94b0e35 Compare March 24, 2026 21:34
out
}

#[cfg(test)]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why not path = truncate_tests.rs

@aibrahim-oai aibrahim-oai merged commit 062fa7a into main Mar 24, 2026
39 of 42 checks passed
@aibrahim-oai aibrahim-oai deleted the codex/extract-string-truncation-utils branch March 24, 2026 22:45
@github-actions github-actions bot locked and limited conversation to collaborators Mar 24, 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