agentydragon(tasks): expose Prompt and FunctionCallOutputPayload; fix test imports

This commit is contained in:
Rai (Michael Pokorny)
2025-06-24 21:02:02 -07:00
parent 332b6666b8
commit a07b897c34
4 changed files with 16 additions and 5 deletions

View File

@@ -30,7 +30,7 @@ We will implement the following high-level plan:
- Add tests under `codex-rs/core/tests/` (e.g. `guard_tool_output_sequencing.rs`) that exercise interleaved input sequences:
- A user message mid-rollout before tool output, ensuring it is delayed until after the tool result.
- Normal flow where no buffering is needed.
- Cancellation or error-result paths that also trigger a flush of buffered messages.
- Cancellation paths (no tool output) inserting a fake "Tool cancelled" tool message and flushing buffered messages.
## Notes

View File

@@ -116,6 +116,18 @@ pub(crate) async fn stream_chat_completions(
}
}
// If a tool invocation was never resolved (e.g. was cancelled), insert a fake cancellation result and flush buffered user inputs
if let Some(call_id) = pending_call.take() {
messages.push(json!({
"role": "tool",
"tool_call_id": call_id,
"content": "Tool cancelled"
}));
for msg in buf_user.drain(..) {
messages.push(msg);
}
}
let tools_json = create_tools_json_for_chat_completions_api(prompt, model)?;
let payload = json!({
"model": model,

View File

@@ -27,7 +27,7 @@ mod model_provider_info;
pub use model_provider_info::ModelProviderInfo;
pub use model_provider_info::WireApi;
mod models;
pub use models::{ContentItem, ReasoningItemReasoningSummary, ResponseItem};
pub use models::{ContentItem, ReasoningItemReasoningSummary, ResponseItem, FunctionCallOutputPayload};
pub mod openai_api_key;
mod openai_tools;
mod project_doc;
@@ -37,4 +37,4 @@ mod safety;
mod user_notification;
pub mod util;
pub use client_common::model_supports_reasoning_summaries;
pub use client_common::{model_supports_reasoning_summaries, Prompt};

View File

@@ -1,6 +1,5 @@
use serde_json::{json, Value};
use codex_core::client_common::Prompt;
use codex_core::models::{ResponseItem, ContentItem, FunctionCallOutputPayload};
use codex_core::{Prompt, ResponseItem, ContentItem, FunctionCallOutputPayload};
/// Reproduce the `messages` JSON construction from `stream_chat_completions`
fn build_messages(input: Vec<ResponseItem>, model: &str) -> Vec<Value> {