The new `codex-mini-latest` model expects a new tool with `{"type":
"local_shell"}`. Its contract is similar to the existing `function` tool
with `"name": "shell"`, so this takes the `local_shell` tool call into
`ExecParams` and sends it through the existing
`handle_container_exec_with_params()` code path.
This also adds the following logic when adding the default set of tools
to a request:
```rust
let default_tools = if self.model.starts_with("codex") {
&DEFAULT_CODEX_MODEL_TOOLS
} else {
&DEFAULT_TOOLS
};
```
That is, if the model name starts with `"codex"`, we add `{"type":
"local_shell"}` to the list of tools; otherwise, we add the
aforementioned `shell` tool.
To test this, I ran the TUI with `-m codex-mini-latest` and verified
that it used the `local_shell` tool. Though I also had some entries in
`[mcp_servers]` in my personal `config.toml`. The `codex-mini-latest`
model seemed eager to try the tools from the MCP servers first, so I
have personally commented them out for now, so keep an eye out if you're
testing `codex-mini-latest`!
Perhaps we should include more details with `{"type": "local_shell"}` or
update the following:
fd0b1b0208/codex-rs/core/prompt.md
For reference, the corresponding change in the TypeScript CLI is
https://github.com/openai/codex/pull/951.
50 lines
1.6 KiB
Rust
50 lines
1.6 KiB
Rust
use crate::models::ResponseItem;
|
|
|
|
/// Transcript of conversation history that is needed:
|
|
/// - for ZDR clients for which previous_response_id is not available, so we
|
|
/// must include the transcript with every API call. This must include each
|
|
/// `function_call` and its corresponding `function_call_output`.
|
|
/// - for clients using the "chat completions" API as opposed to the
|
|
/// "responses" API.
|
|
#[derive(Debug, Clone)]
|
|
pub(crate) struct ConversationHistory {
|
|
/// The oldest items are at the beginning of the vector.
|
|
items: Vec<ResponseItem>,
|
|
}
|
|
|
|
impl ConversationHistory {
|
|
pub(crate) fn new() -> Self {
|
|
Self { items: Vec::new() }
|
|
}
|
|
|
|
/// Returns a clone of the contents in the transcript.
|
|
pub(crate) fn contents(&self) -> Vec<ResponseItem> {
|
|
self.items.clone()
|
|
}
|
|
|
|
/// `items` is ordered from oldest to newest.
|
|
pub(crate) fn record_items<I>(&mut self, items: I)
|
|
where
|
|
I: IntoIterator<Item = ResponseItem>,
|
|
{
|
|
for item in items {
|
|
if is_api_message(&item) {
|
|
// Note agent-loop.ts also does filtering on some of the fields.
|
|
self.items.push(item.clone());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Anything that is not a system message or "reasoning" message is considered
|
|
/// an API message.
|
|
fn is_api_message(message: &ResponseItem) -> bool {
|
|
match message {
|
|
ResponseItem::Message { role, .. } => role.as_str() != "system",
|
|
ResponseItem::FunctionCallOutput { .. }
|
|
| ResponseItem::FunctionCall { .. }
|
|
| ResponseItem::LocalShellCall { .. } => true,
|
|
ResponseItem::Reasoning { .. } | ResponseItem::Other => false,
|
|
}
|
|
}
|