feat: agent nick names to model (#12575)

This commit is contained in:
jif-oai 2026-02-23 13:44:37 +00:00 committed by GitHub
parent 829d1080f6
commit cf0210bf22
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View file

@ -109,6 +109,7 @@ mod spawn {
#[derive(Debug, Serialize)]
struct SpawnAgentResult {
agent_id: String,
nickname: Option<String>,
}
pub async fn handle(
@ -183,6 +184,7 @@ mod spawn {
.unwrap_or((None, None)),
None => (None, None),
};
let nickname = new_agent_nickname.clone();
session
.send_event(
&turn,
@ -202,6 +204,7 @@ mod spawn {
let content = serde_json::to_string(&SpawnAgentResult {
agent_id: new_thread_id.to_string(),
nickname,
})
.map_err(|err| {
FunctionCallError::Fatal(format!("failed to serialize spawn_agent result: {err}"))
@ -1085,6 +1088,7 @@ mod tests {
#[derive(Debug, Deserialize)]
struct SpawnAgentResult {
agent_id: String,
nickname: Option<String>,
}
let (mut session, mut turn) = make_session_and_context().await;
@ -1121,6 +1125,12 @@ mod tests {
let result: SpawnAgentResult =
serde_json::from_str(&content).expect("spawn_agent result should be json");
let agent_id = agent_id(&result.agent_id).expect("agent_id should be valid");
assert!(
result
.nickname
.as_deref()
.is_some_and(|nickname| !nickname.is_empty())
);
let snapshot = manager
.get_thread(agent_id)
.await
@ -1184,6 +1194,7 @@ mod tests {
#[derive(Debug, Deserialize)]
struct SpawnAgentResult {
agent_id: String,
nickname: Option<String>,
}
let (mut session, mut turn) = make_session_and_context().await;
@ -1221,6 +1232,12 @@ mod tests {
let result: SpawnAgentResult =
serde_json::from_str(&content).expect("spawn_agent result should be json");
assert!(!result.agent_id.is_empty());
assert!(
result
.nickname
.as_deref()
.is_some_and(|nickname| !nickname.is_empty())
);
assert_eq!(success, Some(true));
}

View file

@ -557,7 +557,7 @@ fn create_spawn_agent_tool(config: &ToolsConfig) -> ToolSpec {
ToolSpec::Function(ResponsesApiTool {
name: "spawn_agent".to_string(),
description:
"Spawn a sub-agent for a well-scoped task. Returns the agent id to use to communicate with this agent."
"Spawn a sub-agent for a well-scoped task. Returns the agent id (and user-facing nickname when available) to use to communicate with this agent."
.to_string(),
strict: false,
parameters: JsonSchema::Object {