MCPcopy
hub / github.com/wshobson/agents / _rewrite_body_for_codex

Function _rewrite_body_for_codex

tools/adapters/codex.py:185–207  ·  view source on GitHub ↗

Replace 'the Read tool' / 'The Bash tool' / 'the `Grep` tool' -> action verbs. Matches plugin_eval/layers/harness_portability.py's _TOOL_PROSE_PATTERN exactly: the leading article is case-insensitive, but the tool name must match exact CamelCase. This prevents `the bash tool` (referring

(body: str)

Source from the content-addressed store, hash-verified

183
184
185def _rewrite_body_for_codex(body: str) -> str:
186 """Replace 'the Read tool' / 'The Bash tool' / 'the `Grep` tool' -> action verbs.
187
188 Matches plugin_eval/layers/harness_portability.py's _TOOL_PROSE_PATTERN exactly:
189 the leading article is case-insensitive, but the tool name must match exact
190 CamelCase. This prevents `the bash tool` (referring to the shell, lowercase)
191 from being rewritten — it would be a false-positive that the lint correctly
192 leaves alone.
193
194 Codex prompts encourage action verbs over tool-name vocabulary.
195 """
196 import re
197
198 mapping = TOOL_NAME_MAPS["codex"]
199 out = body
200 for camel, replacement in mapping.items():
201 # `(?i:the)` makes only the article case-insensitive; tool name stays CamelCase.
202 out = re.sub(
203 rf"(?i:\bthe)\s+`?{re.escape(camel)}`?\s+tool\b",
204 replacement,
205 out,
206 )
207 return out
208
209
210_POINTER = (

Callers 4

_emit_skillMethod · 0.85
_emit_agentMethod · 0.85

Calls

no outgoing calls

Tested by 1