Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions code-rs/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions code-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ seccompiler = "0.5.0"
serde = "1"
serde_json = "1"
serde_with = "3.14"
serde_yaml = "0.9"
sha1 = "0.10.6"
sha2 = "0.10"
shlex = "1.3.0"
Expand Down Expand Up @@ -252,6 +253,7 @@ codegen-units = 1
[patch.crates-io]
# ratatui = { path = "../../ratatui" }
ratatui = { git = "https://github.com/nornagon/ratatui", branch = "nornagon-v0.29.0-patch" }
cc = { git = "https://github.com/rust-lang/cc-rs", rev = "8a45e2b2e99daf9abe45ae404984dc6a65356ded" }

# Custom build profiles used by build-fast.sh
[profile.dev-fast]
Expand Down
4 changes: 3 additions & 1 deletion code-rs/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ schemars = "0.8.22"
serde = { workspace = true, features = ["derive"] }
serde_bytes = "0.11"
serde_json = { workspace = true }
serde_yaml = "0.9"
serde_yaml = { workspace = true }
sha1 = { workspace = true }
shlex = { workspace = true }
similar = { workspace = true }
Expand All @@ -66,6 +66,7 @@ tokio = { workspace = true, features = [
"macros",
"process",
"rt-multi-thread",
"sync",
"signal",
] }
tokio-util = { workspace = true }
Expand Down Expand Up @@ -107,6 +108,7 @@ maplit = { workspace = true }
once_cell = { workspace = true }
serial_test = "3.2.0"
pretty_assertions = { workspace = true }
tempfile = { workspace = true }
tokio-test = { workspace = true }
wiremock = { workspace = true }

Expand Down
9 changes: 8 additions & 1 deletion code-rs/core/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use crate::chat_completions::stream_chat_completions;
use crate::client_common::Prompt;
use crate::client_common::ResponseEvent;
use crate::client_common::ResponseStream;
use crate::client_common::ResponsesApiRequest;
use crate::client_common::{ResponsesApiRequest, SkillContainer};
use crate::client_common::create_reasoning_param_for_request;
use crate::config::Config;
use crate::config_types::ReasoningEffort as ReasoningEffortConfig;
Expand Down Expand Up @@ -406,6 +406,12 @@ impl ModelClient {
(_, None, None) => None,
};

let container = if prompt.skills.is_empty() {
None
} else {
Some(SkillContainer { skills: &prompt.skills })
};

// In general, we want to explicitly send `store: false` when using the Responses API,
// but in practice, the Azure Responses API rejects `store: false`:
//
Expand Down Expand Up @@ -439,6 +445,7 @@ impl ModelClient {
include,
// Use a stable per-process cache key (session id). With store=false this is inert.
prompt_cache_key: Some(session_id_str.clone()),
container,
};

let mut payload_json = serde_json::to_value(&payload)?;
Expand Down
25 changes: 25 additions & 0 deletions code-rs/core/src/client_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ pub struct Prompt {
pub log_tag: Option<String>,
/// Optional override for session/conversation identifiers used for caching.
pub session_id_override: Option<Uuid>,

/// Enabled skills to advertise to the provider for this turn.
pub skills: Vec<SkillRuntimeSpec>,
}

impl Default for Prompt {
Expand All @@ -98,6 +101,7 @@ impl Default for Prompt {
output_schema: None,
log_tag: None,
session_id_override: None,
skills: Vec::new(),
}
}
}
Expand Down Expand Up @@ -426,6 +430,24 @@ pub(crate) struct ResponsesApiRequest<'a> {
pub(crate) include: Vec<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) prompt_cache_key: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) container: Option<SkillContainer<'a>>,
}

#[derive(Debug, Clone, Serialize)]
pub struct SkillRuntimeSpec {
#[serde(rename = "type")]
pub skill_type: String,
pub name: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub allowed_tools: Option<Vec<String>>,
}

#[derive(Debug, Serialize)]
pub(crate) struct SkillContainer<'a> {
pub(crate) skills: &'a [SkillRuntimeSpec],
}

pub(crate) fn create_reasoning_param_for_request(
Expand Down Expand Up @@ -537,6 +559,7 @@ mod tests {
include: vec![],
prompt_cache_key: None,
text: Some(Text { verbosity: OpenAiTextVerbosity::Low, format: None }),
container: None,
};

let v = serde_json::to_value(&req).expect("json");
Expand Down Expand Up @@ -580,6 +603,7 @@ mod tests {
schema: Some(schema.clone()),
}),
}),
container: None,
};

let v = serde_json::to_value(&req).expect("json");
Expand Down Expand Up @@ -616,6 +640,7 @@ mod tests {
include: vec![],
prompt_cache_key: None,
text: None,
container: None,
};

let v = serde_json::to_value(&req).expect("json");
Expand Down
Loading