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
26 changes: 26 additions & 0 deletions codex-rs/app-server-protocol/schema/json/EventMsg.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
}
]
},
"AgentSpawnMode": {
"enum": [
"spawn",
"fork",
"watchdog"
],
"type": "string"
},
"AgentStatus": {
"description": "Agent lifecycle status, derived from emitted events.",
"oneOf": [
Expand Down Expand Up @@ -2924,6 +2932,15 @@
],
"description": "Thread ID of the sender."
},
"spawn_mode": {
"allOf": [
{
"$ref": "#/definitions/AgentSpawnMode"
}
],
"default": "spawn",
"description": "Spawn mode used for this agent."
},
"status": {
"allOf": [
{
Expand Down Expand Up @@ -8717,6 +8734,15 @@
],
"description": "Thread ID of the sender."
},
"spawn_mode": {
"allOf": [
{
"$ref": "#/definitions/AgentSpawnMode"
}
],
"default": "spawn",
"description": "Spawn mode used for this agent."
},
"status": {
"allOf": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@
}
]
},
"AgentSpawnMode": {
"enum": [
"spawn",
"fork",
"watchdog"
],
"type": "string"
},
"AgentStatus": {
"description": "Agent lifecycle status, derived from emitted events.",
"oneOf": [
Expand Down Expand Up @@ -4155,6 +4163,15 @@
],
"description": "Thread ID of the sender."
},
"spawn_mode": {
"allOf": [
{
"$ref": "#/definitions/AgentSpawnMode"
}
],
"default": "spawn",
"description": "Spawn mode used for this agent."
},
"status": {
"allOf": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@
"title": "AgentMessageDeltaNotification",
"type": "object"
},
"AgentSpawnMode": {
"enum": [
"spawn",
"fork",
"watchdog"
],
"type": "string"
},
"AgentStatus": {
"description": "Agent lifecycle status, derived from emitted events.",
"oneOf": [
Expand Down Expand Up @@ -5692,6 +5700,15 @@
],
"description": "Thread ID of the sender."
},
"spawn_mode": {
"allOf": [
{
"$ref": "#/definitions/AgentSpawnMode"
}
],
"default": "spawn",
"description": "Spawn mode used for this agent."
},
"status": {
"allOf": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!

// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type AgentSpawnMode = "spawn" | "fork" | "watchdog";
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!

// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { AgentSpawnMode } from "./AgentSpawnMode";
import type { AgentStatus } from "./AgentStatus";
import type { ThreadId } from "./ThreadId";

Expand Down Expand Up @@ -30,6 +31,10 @@ new_agent_role?: string | null,
* beginning.
*/
prompt: string,
/**
* Spawn mode used for this agent.
*/
spawn_mode: AgentSpawnMode,
/**
* Last known status of the new agent reported to the sender agent.
*/
Expand Down
1 change: 1 addition & 0 deletions codex-rs/app-server-protocol/schema/typescript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type { AgentReasoningEvent } from "./AgentReasoningEvent";
export type { AgentReasoningRawContentDeltaEvent } from "./AgentReasoningRawContentDeltaEvent";
export type { AgentReasoningRawContentEvent } from "./AgentReasoningRawContentEvent";
export type { AgentReasoningSectionBreakEvent } from "./AgentReasoningSectionBreakEvent";
export type { AgentSpawnMode } from "./AgentSpawnMode";
export type { AgentStatus } from "./AgentStatus";
export type { ApplyPatchApprovalParams } from "./ApplyPatchApprovalParams";
export type { ApplyPatchApprovalRequestEvent } from "./ApplyPatchApprovalRequestEvent";
Expand Down
2 changes: 2 additions & 0 deletions codex-rs/core/src/tools/handlers/multi_agents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use async_trait::async_trait;
use codex_protocol::ThreadId;
use codex_protocol::models::BaseInstructions;
use codex_protocol::models::FunctionCallOutputBody;
use codex_protocol::protocol::AgentSpawnMode;
use codex_protocol::protocol::CollabAgentInteractionBeginEvent;
use codex_protocol::protocol::CollabAgentInteractionEndEvent;
use codex_protocol::protocol::CollabAgentRef;
Expand Down Expand Up @@ -207,6 +208,7 @@ mod spawn {
new_agent_nickname,
new_agent_role,
prompt,
spawn_mode: AgentSpawnMode::Spawn,
status,
}
.into(),
Expand Down
2 changes: 2 additions & 0 deletions codex-rs/exec/tests/event_processor_with_json_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ use codex_protocol::plan_tool::StepStatus;
use codex_protocol::plan_tool::UpdatePlanArgs;
use codex_protocol::protocol::AgentMessageEvent;
use codex_protocol::protocol::AgentReasoningEvent;
use codex_protocol::protocol::AgentSpawnMode;
use codex_protocol::protocol::AgentStatus;
use codex_protocol::protocol::AskForApproval;
use codex_protocol::protocol::CodexErrorInfo;
Expand Down Expand Up @@ -576,6 +577,7 @@ fn collab_spawn_begin_and_end_emit_item_events() {
new_agent_nickname: None,
new_agent_role: None,
prompt: prompt.clone(),
spawn_mode: AgentSpawnMode::Spawn,
status: AgentStatus::Running,
}),
);
Expand Down
34 changes: 34 additions & 0 deletions codex-rs/protocol/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,27 @@ pub const COLLABORATION_MODE_CLOSE_TAG: &str = "</collaboration_mode>";
pub const REALTIME_CONVERSATION_OPEN_TAG: &str = "<realtime_conversation>";
pub const REALTIME_CONVERSATION_CLOSE_TAG: &str = "</realtime_conversation>";
pub const USER_MESSAGE_BEGIN: &str = "## My request for Codex:";
pub const AGENT_INBOX_KIND: &str = "agent_inbox";
pub const AGENT_INBOX_MESSAGE_PREFIX: &str = "[agent_inbox:";

#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, JsonSchema)]
pub struct AgentInboxPayload {
pub injected: bool,
pub kind: String,
pub sender_thread_id: ThreadId,
pub message: String,
}

impl AgentInboxPayload {
pub fn new(sender_thread_id: ThreadId, message: String) -> Self {
Self {
injected: true,
kind: AGENT_INBOX_KIND.to_string(),
sender_thread_id,
message,
}
}
}

/// Submission Queue Entry - requests from user
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
Expand Down Expand Up @@ -2965,6 +2986,16 @@ pub struct CollabAgentSpawnBeginEvent {
pub prompt: String,
}

#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq, JsonSchema, TS, Default)]
#[serde(rename_all = "snake_case")]
#[ts(rename_all = "snake_case")]
pub enum AgentSpawnMode {
#[default]
Spawn,
Fork,
Watchdog,
}

#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, JsonSchema, TS)]
pub struct CollabAgentRef {
/// Thread ID of the receiver/new agent.
Expand Down Expand Up @@ -3008,6 +3039,9 @@ pub struct CollabAgentSpawnEndEvent {
/// Initial prompt sent to the agent. Can be empty to prevent CoT leaking at the
/// beginning.
pub prompt: String,
/// Spawn mode used for this agent.
#[serde(default)]
pub spawn_mode: AgentSpawnMode,
/// Last known status of the new agent reported to the sender agent.
pub status: AgentStatus,
}
Expand Down
3 changes: 1 addition & 2 deletions codex-rs/tui/src/app_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
//! Exit is modelled explicitly via `AppEvent::Exit(ExitMode)` so callers can request shutdown-first
//! quits without reaching into the app loop or coupling to shutdown/exit sequencing.

use std::path::PathBuf;

use codex_chatgpt::connectors::AppInfo;
use codex_file_search::FileMatch;
use codex_protocol::ThreadId;
use codex_protocol::openai_models::ModelPreset;
use codex_protocol::protocol::Event;
use codex_protocol::protocol::RateLimitSnapshot;
use codex_utils_approval_presets::ApprovalPreset;
use std::path::PathBuf;

use crate::bottom_pane::ApprovalRequest;
use crate::bottom_pane::StatusLineItem;
Expand Down
Loading
Loading