Overview
Seek a second opinion from the consultation-target Agent (Codex CLI / OpenAI), summarize the result, and report it to the user. The user does not need to see codex's raw output directly. The consulting Agent digests codex's answer, compares it against its own view, and reports.
Participants
This procedure involves three parties:
- User: The human requesting the consultation
- Consulting Agent: The Agent itself executing this procedure. Upon the user's request, it consults with the consultation-target Agent and reports the result to the user
- Consultation-target Agent (Codex CLI): The external Agent that provides the second opinion
When reporting to the user, use your own Agent name in the heading (e.g., "Claude Code's View," "Cline's View," etc.).
1. Check codex installation
Run the following with the Bash tool:
command -v codex
If codex is not found, report to the user that "Codex CLI is not installed" and stop. Do not perform any further work.
2. Confirm consultation depth
If the user has not explicitly specified the consultation depth (if there is no specification such as "with full effort," "deeply," "thoroughly," or "lightly"), use the AskUserQuestion tool to present the following three options:
| Option | Number of round trips | Consulting Agent's tentative view | Degree of pursuing omissions and gaps |
|---|---|---|---|
| Consult thoroughly(Recommended) | 2 round trips as needed | Determined by the consulting Agent | Check for omissions and gaps and report |
| Consult deeply with full effort | In principle, perform 2 round trips (skip only when clearly unnecessary) | Always include it, and if there is anything considered but not adopted, write the reason as well, prompting verification of its validity | Actively rebut, supplement, and pursue further |
| Consult lightly | 1 round trip only | Determined by the consulting Agent | Organize Codex's points and report |
If the user has explicitly specified the depth, omit this confirmation and follow the specification.
3. Designing the prompt
The consulting Agent designs the prompt to pass to codex. Follow the guidelines below:
Prompt design guidelines
- Determine "what should be consulted about now" from the conversation context
- If the user has explicitly specified a theme, follow it
- If no specification is given, choose an appropriate theme from the immediately preceding discussion or work content
Prompt examples by context
When you want to review uncommitted changes
"Please review the uncommitted changes in this repository. Point out code quality, design validity, potential bugs, and areas for improvement."
When you want to consult about design
"Please give your opinion on the following design. [Summary of the design]. If there are alternatives or trade-offs, please propose them."
When you want to consult about the implementation approach
"I want to implement [summary of the task]. Based on this repository's codebase, please propose the optimal implementation approach."
Prompt structure
- Project background (briefly)
- The specific content you want to consult about
- The consulting source Agent's provisional view at this point in time. Always include it in "full power" mode, and include it depending on the situation in other modes
- Request to explore broadly beyond the specified perspectives (always include)
Template for when including the consulting source Agent's provisional view
In the provisional view, write the current view and its rationale. If there are matters you considered but did not adopt, also write their content and the reason for not adopting them, and make them subject to verification by the consultation destination. Do not write matters you have not considered as matters you did not adopt.
なお相談元Agent([自分のAgent名])は現時点で以下のように考えている:
- 現時点の見解: [見解とその理由]
- 検討したが採用しない事: [採用しない事とその理由]
見解に漏れや誤りが無いか、採用しない判断の理由・根拠・前提が妥当かを検証し、反論があれば示してほしい。
相談元Agentが検討していない選択肢があれば挙げてほしい。
指定した観点以外にも気になる点があれば積極的に報告してほしい。
Request for broad exploration (always include in the prompt)
The specified perspectives are merely a starting point, not constraints. Always include in the prompt a statement to the effect that if you explore the repository yourself and find anything of concern, you should actively report it.
4. Running codex
Write the prompt to a temporary file and execute it with the Bash tool in the following format:
codex exec --ephemeral -s workspace-write -c sandbox_workspace_write.network_access=true < /path/to/prompt.md
Important options
--ephemeralis required. Do not save the session-s workspace-write -c sandbox_workspace_write.network_access=trueis required. By default, the sandbox blocks network access, soghやcurlExternal communication commands such as these fail- When the user or the calling skill specifies Codex's model or reasoning effort,
-m <model>と-c model_reasoning_effort=<effort>Override with this. There is no dedicated flag for reasoning effort; it is passed by overriding the setting value. When there is no specification, do not override, and use the codex command's default settings as they are -mWhat is passed to is the model ID. When specified by a display name or alias such as "Astra",codex debug modelsResolve the ID from the display name using the model catalog output by . When there are multiple models with the same name that differ only in generation, choose the one with the newest version number. The catalog also lists the reasoning effort supported by each model- As the working directory, the current directory is used as is
- If the current directory is not inside a git repository, codex exits without starting. The error message looks like a trust setting issue, but the only criterion is whether it is inside a git repository. When consulting in a non-git directory,
--skip-git-repo-checkAdd this - Pass the prompt via stdin. If passed as a CLI argument, when stdin is in a pipe state, codex will read additional input
<stdin>as a block and wait until EOF, causing a hang. - Place the prompt file outside the repository's working tree. If placed inside the working tree, it will appear as an uncommitted change and pollute the review target.
Timeout
Running codex may take time. Set the Bash tool's timeout to 900000 (15 minutes).
Handling output
For output, retain both standard output and standard error without omission. The answer appears on standard output, so summarize from there. Standard error begins with a header showing the Codex CLI version, model, and reasoning effort, followed by the progress of codex's work. Take the execution environment line for the report from this header, and also check the progress for signs of command failure.tail If you look only at the end, you lose the header.
Deciding on additional round trips
In "full power" mode, after receiving the result of the first round trip, in principle carry out a second round trip. Skip only when additional deep exploration is clearly unnecessary (when a sufficiently comprehensive answer was obtained in the first round trip).
In "well" mode, after receiving the result of the first round trip, carry out a second round trip if any of the following applies:
- Codex's points include important points that should be explored further
- The consulting Agent has something to rebut or supplement regarding Codex's points
- The consulting Agent can judge that there are areas that have not been sufficiently explored
Before deciding on the second round trip, check whether there are signs of command failure in the output of the first round trip. If a failure is detected, the consulting Agent should first obtain and correct the correct information, and then decide whether a second round trip is necessary (for details, see Section 5, "When a codex command failure is detected").
Prompt structure for the second round trip:
Note: codex execis a single execution, so the Codex in the second round trip has no memory of the first round trip. It is necessary to include all context from the beginning.
- Re-presentation of the original consultation content (include it in a structured way without omitting background/purpose/constraints/evaluation perspectives)
- Summary of Codex's answer in the first round trip
- The consulting Agent's rebuttal, supplement, or additional questions
- Perspectives to be explored further
In principle, round trips are limited to two. For three or more, confirm with the user before carrying them out.
5. Summarizing and reporting results
Read codex's output and report to the user with the following structure:
Report structure
Content consulted with codex
Read codex's execution environment from the header at the beginning of standard error, andCodex CLI v0.153.4 (gpt-6-astra, reasoning effort: high) write one line in the format, then explain the outline of the prompt sent to codex in 1-2 sentences.
Summary of codex's answer
Summarize codex's main points and suggestions in bullet points.
[Your own Agent name]'s view
- Among codex's points, those you agree with
- Among codex's points, those you have differing opinions on (with reasons)
- Points you consider codex to have overlooked
- If a second round was conducted, the reason for it and what became clear in the second round
Stance on views:
- Do not readily accept codex's points. As the requesting Agent, try to verify them before reporting
- Consciously explore areas that codex may not have explored
- If the views of codex and the requesting Agent conflict, actively communicate that conflict as valuable information
Proposed next actions
Indicate matters to discuss with the user and recommended next steps.
Reporting style
- Keep it concise. Avoid redundant quotations
- If the views of codex and the requesting Agent differ, explain both reasons so the user can make a judgment
- Clarify what the user should do next
If codex's response is too large
If you determine that codex's response is long and difficult to summarize or process, follow these steps:
- First, report to the user that "codex's response was extremely long"
- Convey only an overview of the portion of the response that could be read
- Discuss with the user and decide how to handle it (e.g., rerun with narrowed perspectives, add an output volume constraint to the prompt, etc.)
Do not limit the output volume in the prompt in advance. Limiting it risks important information being omitted.
If a codex command failure is detected
When reading codex's output, carefully check for signs of command execution failure. Examples of signs: error messages, "could not obtain", "failed", "permission denied", "not found", etc.
If a failure is detected, follow these steps:
- First, the requesting Agent obtains the correct information itself. Run the command that codex failed at (e.g.,
gh pr view) with the Bash tool and check the result - Next, correct codex's analysis with the obtained information. Identify points that became off-target due to insufficient information and reevaluate them in the correct context
- Finally, make the information shortage explicit in the views section of the report. Specifically explain the missing information and the points affected by it
6. Improvement proposals
If you recognize a pattern in which codex made some kind of failure, advise the user on improvement measures for subsequent occasions.