Repair Soul source-tool continuations
This commit is contained in:
parent
f3cb4a57c8
commit
898c81d259
8 changed files with 346 additions and 29 deletions
|
|
@ -620,6 +620,11 @@ fn model_input_item_chars(item: &EpiphanyModelInputItem) -> usize {
|
|||
match item {
|
||||
EpiphanyModelInputItem::UserText { text }
|
||||
| EpiphanyModelInputItem::AssistantText { text } => text.chars().count(),
|
||||
EpiphanyModelInputItem::ToolCall {
|
||||
call_id,
|
||||
name,
|
||||
arguments,
|
||||
} => call_id.chars().count() + name.chars().count() + arguments.chars().count(),
|
||||
EpiphanyModelInputItem::ToolResult { output, .. } => output.chars().count(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,6 +95,11 @@ pub struct EpiphanyModelToolDefinition {
|
|||
pub enum EpiphanyModelInputItem {
|
||||
UserText { text: String },
|
||||
AssistantText { text: String },
|
||||
ToolCall {
|
||||
call_id: String,
|
||||
name: String,
|
||||
arguments: String,
|
||||
},
|
||||
ToolResult { call_id: String, output: String },
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -106,6 +106,11 @@ pub struct EpiphanyOpenAiToolDefinition {
|
|||
pub enum EpiphanyOpenAiInputItem {
|
||||
UserText { text: String },
|
||||
AssistantText { text: String },
|
||||
ToolCall {
|
||||
call_id: String,
|
||||
name: String,
|
||||
arguments: String,
|
||||
},
|
||||
ToolResult { call_id: String, output: String },
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
|
|
@ -207,7 +208,11 @@ impl EpiphanyCodexOpenAiTransport {
|
|||
pub fn responses_body_from_epiphany(
|
||||
request: EpiphanyOpenAiModelRequest,
|
||||
) -> Result<serde_json::Value> {
|
||||
let has_tools = !request.tools.is_empty();
|
||||
let requires_initial_tool = !request.tools.is_empty()
|
||||
&& !request
|
||||
.input
|
||||
.iter()
|
||||
.any(|item| matches!(item, EpiphanyOpenAiInputItem::ToolResult { .. }));
|
||||
let body = EpiphanyResponsesBody {
|
||||
model: request.model,
|
||||
instructions: request.instructions,
|
||||
|
|
@ -221,7 +226,7 @@ pub fn responses_body_from_epiphany(
|
|||
.into_iter()
|
||||
.map(openai_tool_from_epiphany_tool)
|
||||
.collect::<Result<Vec<_>>>()?,
|
||||
tool_choice: if has_tools { "required" } else { "auto" }.to_string(),
|
||||
tool_choice: if requires_initial_tool { "required" } else { "auto" }.to_string(),
|
||||
parallel_tool_calls: false,
|
||||
reasoning: Some(EpiphanyResponsesReasoning {
|
||||
effort: parse_reasoning_effort(request.reasoning_effort.as_deref())?,
|
||||
|
|
@ -293,6 +298,11 @@ enum EpiphanyResponsesInputItem {
|
|||
role: String,
|
||||
content: Vec<EpiphanyResponsesContentItem>,
|
||||
},
|
||||
FunctionCall {
|
||||
call_id: String,
|
||||
name: String,
|
||||
arguments: String,
|
||||
},
|
||||
FunctionCallOutput {
|
||||
call_id: String,
|
||||
output: String,
|
||||
|
|
@ -318,6 +328,15 @@ fn openai_input_item_from_epiphany_input(
|
|||
role: "assistant".to_string(),
|
||||
content: vec![EpiphanyResponsesContentItem::OutputText { text }],
|
||||
},
|
||||
EpiphanyOpenAiInputItem::ToolCall {
|
||||
call_id,
|
||||
name,
|
||||
arguments,
|
||||
} => EpiphanyResponsesInputItem::FunctionCall {
|
||||
call_id,
|
||||
name,
|
||||
arguments,
|
||||
},
|
||||
EpiphanyOpenAiInputItem::ToolResult { call_id, output } => {
|
||||
EpiphanyResponsesInputItem::FunctionCallOutput { call_id, output }
|
||||
}
|
||||
|
|
@ -329,6 +348,7 @@ struct EpiphanyResponsesStreamEvent {
|
|||
#[serde(rename = "type")]
|
||||
kind: String,
|
||||
response: Option<Value>,
|
||||
item: Option<Value>,
|
||||
item_id: Option<String>,
|
||||
call_id: Option<String>,
|
||||
delta: Option<String>,
|
||||
|
|
@ -359,9 +379,17 @@ struct EpiphanyResponsesStreamState {
|
|||
sequence: u64,
|
||||
frame_sequence: u64,
|
||||
completed: bool,
|
||||
pending_tool_calls: HashMap<String, PendingToolCall>,
|
||||
events: Vec<EpiphanyOpenAiStreamEvent>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
struct PendingToolCall {
|
||||
call_id: Option<String>,
|
||||
name: Option<String>,
|
||||
arguments: String,
|
||||
}
|
||||
|
||||
impl EpiphanyResponsesStreamState {
|
||||
fn new(request_id: &str, requested_model: &str) -> Self {
|
||||
Self {
|
||||
|
|
@ -370,6 +398,7 @@ impl EpiphanyResponsesStreamState {
|
|||
sequence: 0,
|
||||
frame_sequence: 0,
|
||||
completed: false,
|
||||
pending_tool_calls: HashMap::new(),
|
||||
events: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
|
@ -400,15 +429,47 @@ impl EpiphanyResponsesStreamState {
|
|||
}
|
||||
true
|
||||
}
|
||||
"response.custom_tool_call_input.delta" => {
|
||||
if let (Some(arguments), Some(name)) =
|
||||
"response.output_item.added" => {
|
||||
if let Some(item) = event.item {
|
||||
self.seed_tool_call_from_item(&item);
|
||||
}
|
||||
true
|
||||
}
|
||||
"response.function_call_arguments.delta" => {
|
||||
if let (Some(arguments), Some(item_id)) =
|
||||
(event.delta, event.item_id.clone().or(event.call_id.clone()))
|
||||
{
|
||||
self.push_payload(EpiphanyOpenAiStreamPayload::ToolCall {
|
||||
call_id: event.call_id.unwrap_or_else(|| name.clone()),
|
||||
name,
|
||||
arguments,
|
||||
});
|
||||
self.pending_tool_calls
|
||||
.entry(item_id.clone())
|
||||
.or_insert_with(|| PendingToolCall {
|
||||
call_id: event.call_id.clone().or(Some(item_id)),
|
||||
name: None,
|
||||
arguments: String::new(),
|
||||
})
|
||||
.arguments
|
||||
.push_str(&arguments);
|
||||
}
|
||||
true
|
||||
}
|
||||
"response.custom_tool_call_input.delta" => {
|
||||
if let (Some(arguments), Some(item_id)) =
|
||||
(event.delta, event.item_id.clone().or(event.call_id.clone()))
|
||||
{
|
||||
self.pending_tool_calls
|
||||
.entry(item_id.clone())
|
||||
.or_insert_with(|| PendingToolCall {
|
||||
call_id: event.call_id.clone().or(Some(item_id)),
|
||||
name: None,
|
||||
arguments: String::new(),
|
||||
})
|
||||
.arguments
|
||||
.push_str(&arguments);
|
||||
}
|
||||
true
|
||||
}
|
||||
"response.output_item.done" => {
|
||||
if let Some(item) = event.item {
|
||||
self.push_tool_call_from_done_item(&item);
|
||||
}
|
||||
true
|
||||
}
|
||||
|
|
@ -452,6 +513,56 @@ impl EpiphanyResponsesStreamState {
|
|||
self.push_payload(EpiphanyOpenAiStreamPayload::Completed { receipt });
|
||||
}
|
||||
|
||||
fn seed_tool_call_from_item(&mut self, item: &Value) {
|
||||
let Some(kind) = item_type(item) else {
|
||||
return;
|
||||
};
|
||||
if kind != "function_call" && kind != "custom_tool_call" {
|
||||
return;
|
||||
}
|
||||
let Some(item_id) = item_identity(item) else {
|
||||
return;
|
||||
};
|
||||
let pending = self.pending_tool_calls.entry(item_id.clone()).or_default();
|
||||
if pending.call_id.is_none() {
|
||||
pending.call_id = item_call_id(item).or(Some(item_id));
|
||||
}
|
||||
if pending.name.is_none() {
|
||||
pending.name = item_name(item);
|
||||
}
|
||||
if pending.arguments.is_empty()
|
||||
&& let Some(arguments) = item_arguments(item)
|
||||
{
|
||||
pending.arguments = arguments;
|
||||
}
|
||||
}
|
||||
|
||||
fn push_tool_call_from_done_item(&mut self, item: &Value) {
|
||||
let Some(kind) = item_type(item) else {
|
||||
return;
|
||||
};
|
||||
if kind != "function_call" && kind != "custom_tool_call" {
|
||||
return;
|
||||
}
|
||||
let item_id = item_identity(item);
|
||||
let pending = item_id
|
||||
.as_ref()
|
||||
.and_then(|id| self.pending_tool_calls.remove(id))
|
||||
.unwrap_or_default();
|
||||
let Some(name) = item_name(item).or(pending.name) else {
|
||||
return;
|
||||
};
|
||||
let Some(call_id) = item_call_id(item).or(pending.call_id).or(item_id) else {
|
||||
return;
|
||||
};
|
||||
let arguments = item_arguments(item).unwrap_or(pending.arguments);
|
||||
self.push_payload(EpiphanyOpenAiStreamPayload::ToolCall {
|
||||
call_id,
|
||||
name,
|
||||
arguments,
|
||||
});
|
||||
}
|
||||
|
||||
fn push_failed(&mut self, message: String) {
|
||||
self.push_payload(EpiphanyOpenAiStreamPayload::Failed { message });
|
||||
self.completed = true;
|
||||
|
|
@ -477,6 +588,37 @@ fn delta_preview(delta: &str) -> String {
|
|||
preview.replace(['\r', '\n', '\t'], " ")
|
||||
}
|
||||
|
||||
fn item_type(item: &Value) -> Option<&str> {
|
||||
item.get("type").and_then(Value::as_str)
|
||||
}
|
||||
|
||||
fn item_identity(item: &Value) -> Option<String> {
|
||||
item.get("id")
|
||||
.and_then(Value::as_str)
|
||||
.or_else(|| item.get("item_id").and_then(Value::as_str))
|
||||
.or_else(|| item.get("call_id").and_then(Value::as_str))
|
||||
.map(ToString::to_string)
|
||||
}
|
||||
|
||||
fn item_call_id(item: &Value) -> Option<String> {
|
||||
item.get("call_id")
|
||||
.and_then(Value::as_str)
|
||||
.map(ToString::to_string)
|
||||
}
|
||||
|
||||
fn item_name(item: &Value) -> Option<String> {
|
||||
item.get("name")
|
||||
.and_then(Value::as_str)
|
||||
.map(ToString::to_string)
|
||||
}
|
||||
|
||||
fn item_arguments(item: &Value) -> Option<String> {
|
||||
item.get("arguments")
|
||||
.or_else(|| item.get("input"))
|
||||
.and_then(Value::as_str)
|
||||
.map(ToString::to_string)
|
||||
}
|
||||
|
||||
fn parse_reasoning_effort(value: Option<&str>) -> Result<Option<String>> {
|
||||
match value {
|
||||
None => Ok(None),
|
||||
|
|
@ -630,6 +772,15 @@ mod tests {
|
|||
request.input.push(EpiphanyOpenAiInputItem::UserText {
|
||||
text: "hello".to_string(),
|
||||
});
|
||||
request.input.push(EpiphanyOpenAiInputItem::ToolCall {
|
||||
call_id: "call-1".to_string(),
|
||||
name: "mcp__epiphany_source__read_file".to_string(),
|
||||
arguments: "{\"path\":\"README.md\"}".to_string(),
|
||||
});
|
||||
request.input.push(EpiphanyOpenAiInputItem::ToolResult {
|
||||
call_id: "call-1".to_string(),
|
||||
output: "{\"ok\":true}".to_string(),
|
||||
});
|
||||
request.reasoning_effort = Some("low".to_string());
|
||||
request.reasoning_summary = Some("concise".to_string());
|
||||
request.service_tier = Some("flex".to_string());
|
||||
|
|
@ -653,6 +804,12 @@ mod tests {
|
|||
assert_eq!(responses["instructions"], "Answer plainly.");
|
||||
assert_eq!(responses["previous_response_id"], "resp-1");
|
||||
assert_eq!(responses["input"][0]["content"][0]["type"], "input_text");
|
||||
assert_eq!(responses["input"][1]["type"], "function_call");
|
||||
assert_eq!(
|
||||
responses["input"][1]["name"],
|
||||
"mcp__epiphany_source__read_file"
|
||||
);
|
||||
assert_eq!(responses["input"][2]["type"], "function_call_output");
|
||||
assert_eq!(responses["stream"], true);
|
||||
assert_eq!(responses["store"], false);
|
||||
assert_eq!(responses["service_tier"], "flex");
|
||||
|
|
@ -661,6 +818,122 @@ mod tests {
|
|||
responses["tools"][0]["name"],
|
||||
"mcp__epiphany_source__read_file"
|
||||
);
|
||||
assert_eq!(responses["tool_choice"], "auto");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tool_bearing_initial_request_requires_one_tool_call() {
|
||||
let mut request = EpiphanyOpenAiModelRequest::new(
|
||||
"req-1",
|
||||
"conversation-1",
|
||||
"gpt-5.4",
|
||||
"Inspect before answering.",
|
||||
);
|
||||
request.input.push(EpiphanyOpenAiInputItem::UserText {
|
||||
text: "verify".to_string(),
|
||||
});
|
||||
request
|
||||
.tools
|
||||
.push(epiphany_openai_adapter::EpiphanyOpenAiToolDefinition {
|
||||
name: "mcp__epiphany_source__read_file".to_string(),
|
||||
description: "Read a bounded file slice.".to_string(),
|
||||
parameters_json: serde_json::json!({
|
||||
"type": "object",
|
||||
"properties": {"path": {"type": "string"}},
|
||||
"required": ["path"]
|
||||
})
|
||||
.to_string(),
|
||||
});
|
||||
|
||||
let responses = responses_body_from_epiphany(request).expect("request should map");
|
||||
|
||||
assert_eq!(responses["tool_choice"], "required");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_function_call_output_item_done_as_complete_tool_call() {
|
||||
let mut state = EpiphanyResponsesStreamState::new("req-tools", "gpt-5.4");
|
||||
let observation = state.push_sse_frame(
|
||||
&serde_json::json!({
|
||||
"type": "response.output_item.done",
|
||||
"item": {
|
||||
"id": "fc_1",
|
||||
"type": "function_call",
|
||||
"name": "mcp__epiphany_source__read_file",
|
||||
"arguments": "{\"path\":\"README.md\"}",
|
||||
"call_id": "call_1"
|
||||
}
|
||||
})
|
||||
.to_string(),
|
||||
);
|
||||
|
||||
assert!(observation.recognized);
|
||||
assert_eq!(state.events.len(), 1);
|
||||
assert_eq!(
|
||||
state.events[0].payload,
|
||||
EpiphanyOpenAiStreamPayload::ToolCall {
|
||||
call_id: "call_1".to_string(),
|
||||
name: "mcp__epiphany_source__read_file".to_string(),
|
||||
arguments: "{\"path\":\"README.md\"}".to_string(),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn assembles_function_call_argument_deltas_until_output_item_done() {
|
||||
let mut state = EpiphanyResponsesStreamState::new("req-tools", "gpt-5.4");
|
||||
state.push_sse_frame(
|
||||
&serde_json::json!({
|
||||
"type": "response.output_item.added",
|
||||
"item": {
|
||||
"id": "fc_1",
|
||||
"type": "function_call",
|
||||
"name": "mcp__epiphany_source__git_show",
|
||||
"call_id": "call_1",
|
||||
"arguments": ""
|
||||
}
|
||||
})
|
||||
.to_string(),
|
||||
);
|
||||
state.push_sse_frame(
|
||||
&serde_json::json!({
|
||||
"type": "response.function_call_arguments.delta",
|
||||
"item_id": "fc_1",
|
||||
"call_id": "call_1",
|
||||
"delta": "{\"revision\":"
|
||||
})
|
||||
.to_string(),
|
||||
);
|
||||
state.push_sse_frame(
|
||||
&serde_json::json!({
|
||||
"type": "response.function_call_arguments.delta",
|
||||
"item_id": "fc_1",
|
||||
"call_id": "call_1",
|
||||
"delta": "\"HEAD\"}"
|
||||
})
|
||||
.to_string(),
|
||||
);
|
||||
state.push_sse_frame(
|
||||
&serde_json::json!({
|
||||
"type": "response.output_item.done",
|
||||
"item": {
|
||||
"id": "fc_1",
|
||||
"type": "function_call",
|
||||
"name": "mcp__epiphany_source__git_show",
|
||||
"call_id": "call_1"
|
||||
}
|
||||
})
|
||||
.to_string(),
|
||||
);
|
||||
|
||||
assert_eq!(state.events.len(), 1);
|
||||
assert_eq!(
|
||||
state.events[0].payload,
|
||||
EpiphanyOpenAiStreamPayload::ToolCall {
|
||||
call_id: "call_1".to_string(),
|
||||
name: "mcp__epiphany_source__git_show".to_string(),
|
||||
arguments: "{\"revision\":\"HEAD\"}".to_string(),
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -256,6 +256,11 @@ fn openai_request_input_metrics(request: &EpiphanyOpenAiModelRequest) -> (usize,
|
|||
chars += match item {
|
||||
EpiphanyOpenAiInputItem::UserText { text }
|
||||
| EpiphanyOpenAiInputItem::AssistantText { text } => text.chars().count(),
|
||||
EpiphanyOpenAiInputItem::ToolCall {
|
||||
call_id,
|
||||
name,
|
||||
arguments,
|
||||
} => call_id.chars().count() + name.chars().count() + arguments.chars().count(),
|
||||
EpiphanyOpenAiInputItem::ToolResult { output, .. } => output.chars().count(),
|
||||
};
|
||||
}
|
||||
|
|
@ -813,12 +818,6 @@ pub fn build_tool_followup_model_request(
|
|||
let original = cache
|
||||
.get::<EpiphanyModelRequest>(&model_request_key(original_request_id))?
|
||||
.ok_or_else(|| anyhow!("model request {original_request_id:?} does not exist"))?;
|
||||
let receipt = cache
|
||||
.get::<EpiphanyModelReceipt>(&model_receipt_key(original_request_id))?
|
||||
.ok_or_else(|| anyhow!("model receipt {original_request_id:?} does not exist"))?;
|
||||
let previous_response_id = receipt.provider_response_id.clone().ok_or_else(|| {
|
||||
anyhow!("model receipt {original_request_id:?} has no provider_response_id")
|
||||
})?;
|
||||
let original_prefix = format!("model-{}-", sanitize_request_id(original_request_id));
|
||||
let mut followup_items = Vec::new();
|
||||
for intent in cache.get_all::<EpiphanyToolInvocationIntent>()? {
|
||||
|
|
@ -852,16 +851,20 @@ pub fn build_tool_followup_model_request(
|
|||
|
||||
let mut followup = original;
|
||||
followup.request_id = followup_request_id.to_string();
|
||||
followup.previous_response_id = Some(previous_response_id);
|
||||
followup.input = followup_items
|
||||
.into_iter()
|
||||
.map(
|
||||
|(intent, call_id, receipt)| EpiphanyModelInputItem::ToolResult {
|
||||
call_id,
|
||||
output: tool_receipt_output_for_model(&intent, &receipt),
|
||||
},
|
||||
)
|
||||
.collect();
|
||||
followup.previous_response_id = None;
|
||||
let mut input = followup.input.clone();
|
||||
for (intent, call_id, receipt) in followup_items {
|
||||
input.push(EpiphanyModelInputItem::ToolCall {
|
||||
call_id: call_id.clone(),
|
||||
name: format!("mcp__{}__{}", intent.server, intent.tool_name),
|
||||
arguments: intent.arguments_json.clone(),
|
||||
});
|
||||
input.push(EpiphanyModelInputItem::ToolResult {
|
||||
call_id,
|
||||
output: tool_receipt_output_for_model(&intent, &receipt),
|
||||
});
|
||||
}
|
||||
followup.input = input;
|
||||
Ok(followup)
|
||||
}
|
||||
|
||||
|
|
@ -1083,6 +1086,15 @@ fn model_input_from_openai_input(input: &EpiphanyOpenAiInputItem) -> EpiphanyMod
|
|||
EpiphanyOpenAiInputItem::AssistantText { text } => {
|
||||
EpiphanyModelInputItem::AssistantText { text: text.clone() }
|
||||
}
|
||||
EpiphanyOpenAiInputItem::ToolCall {
|
||||
call_id,
|
||||
name,
|
||||
arguments,
|
||||
} => EpiphanyModelInputItem::ToolCall {
|
||||
call_id: call_id.clone(),
|
||||
name: name.clone(),
|
||||
arguments: arguments.clone(),
|
||||
},
|
||||
EpiphanyOpenAiInputItem::ToolResult { call_id, output } => {
|
||||
EpiphanyModelInputItem::ToolResult {
|
||||
call_id: call_id.clone(),
|
||||
|
|
@ -1100,6 +1112,15 @@ fn openai_input_from_model_input(input: &EpiphanyModelInputItem) -> EpiphanyOpen
|
|||
EpiphanyModelInputItem::AssistantText { text } => {
|
||||
EpiphanyOpenAiInputItem::AssistantText { text: text.clone() }
|
||||
}
|
||||
EpiphanyModelInputItem::ToolCall {
|
||||
call_id,
|
||||
name,
|
||||
arguments,
|
||||
} => EpiphanyOpenAiInputItem::ToolCall {
|
||||
call_id: call_id.clone(),
|
||||
name: name.clone(),
|
||||
arguments: arguments.clone(),
|
||||
},
|
||||
EpiphanyModelInputItem::ToolResult { call_id, output } => {
|
||||
EpiphanyOpenAiInputItem::ToolResult {
|
||||
call_id: call_id.clone(),
|
||||
|
|
@ -1968,10 +1989,18 @@ mod tests {
|
|||
let followup =
|
||||
build_tool_followup_model_request(&store, "req-tools", "req-tools-followup")?;
|
||||
assert_eq!(followup.request_id, "req-tools-followup");
|
||||
assert_eq!(followup.previous_response_id.as_deref(), Some("resp-tools"));
|
||||
assert_eq!(followup.input.len(), 1);
|
||||
assert_eq!(followup.previous_response_id, None);
|
||||
assert_eq!(followup.input.len(), 2);
|
||||
assert_eq!(
|
||||
followup.input[0],
|
||||
EpiphanyModelInputItem::ToolCall {
|
||||
call_id: "call-original".to_string(),
|
||||
name: "mcp__smoke_server__smoke_tool".to_string(),
|
||||
arguments: "{}".to_string()
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
followup.input[1],
|
||||
EpiphanyModelInputItem::ToolResult {
|
||||
call_id: "call-original".to_string(),
|
||||
output: r#"{"ok":true}"#.to_string()
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ remembers doctrine; the branch remembers the blade.
|
|||
- `epiphany-model-runtime` is the current provider-neutral executable boundary. It is built by the `epiphany-openai-runtime` crate for now and accepts `--provider openai-codex`; the old `epiphany-openai-runtime` binary, `--openai-runtime-bin`, and `openai-runtime` executor name survive only as compatibility aliases. Coordinator run mode, local wrapper run mode, and repo birth runner should call `--model-runtime-bin` plus `--model-provider`. The runtime default model is `gpt-5.4`, with `EPIPHANY_MODEL` / `CODEX_MODEL` as overrides; `gpt-5.5` was rejected by this Codex-compatible transport as requiring a newer Codex. The typed request/event/receipt contract is now provider-neutral in `epiphany-model-adapter` as `epiphany.model_request.v0`, `epiphany.model_stream_event.v0`, `epiphany.model_receipt.v0`, and `epiphany.model_adapter_status.v0`; OpenAI/Codex documents are adapter evidence behind that boundary, not scheduler/status/state authority.
|
||||
- Epiphany prompt authority is now explicitly Codex-free and core-owned. Bundled specialist prompts live in `epiphany-core/src/prompts/epiphany_specialists.toml`; `epiphany-core::agent_launch` owns prompt parsing/rendering, role/reorient launch instructions, role binding ids, output schemas, coordinator note rendering, and CRRC pre-compaction prompt rendering. `epiphany-codex-bridge/src/launch.rs` is only a compatibility facade for Codex-facing callers, and bridge pressure rendering delegates back to core. The no-Codex prompt authority regression test lives beside that core owner, and `epiphany-repo-birth-runner` no longer accepts `codex-exec` or `--codex-bin`. Use `epiphany-model-runtime` for startup-only birth specialists so Codex cannot wrap Epiphany agents in its own prompt machinery.
|
||||
- Coordinator plan/run passes now emit `epiphany.coordinator_run_receipt.v0` into runtime-spine. `coordinator-summary.json` and `coordinator-steps.jsonl` remain useful operator artifacts, but the durable receipt of what the coordinator decided is typed CultCache/CultNet state.
|
||||
- The first tool/MCP contract surface exists in `epiphany-tool-adapter`: `epiphany.tool_capability.v0`, `epiphany.tool_invocation_intent.v0`, and `epiphany.tool_invocation_receipt.v0`. Runtime-spine advertises these as the Epiphany-facing tool boundary. `epiphany-model-runtime` now materializes complete MCP-shaped model tool calls as typed invocation intents, and `epiphany-tool-codex-mcp-spine` is the quarantined executing adapter: it consumes one typed invocation intent from the mixed runtime-spine CultCache store, executes the built-in read-only `epiphany_source` server for bounded file reads, git diff/show previews, and Hands receipt body readback, or calls user-declared Codex MCP through `codex-mcp`, then emits a typed invocation receipt. Raw MCP JSON remains protocol-edge cargo; Codex MCP is transport scaffolding, not Epiphany state, prompt, scheduler, or policy authority. Verification/Soul worker requests now advertise `mcp__epiphany_source__read_file`, `mcp__epiphany_source__git_show`, and `mcp__epiphany_source__read_hands_receipt`; OpenAI/Codex lowering uses `tool_choice=required` whenever tools are present after live dogfood proved `auto` can complete with zero tool calls; and `epiphany-runtime-spine list-model-requests` prints tool counts/names so request contracts are inspectable without sealed transcript access. Soul is instructed to use those tools before returning `needs-evidence` for missing source/artifact/diff/receipt inspectability.
|
||||
- The first tool/MCP contract surface exists in `epiphany-tool-adapter`: `epiphany.tool_capability.v0`, `epiphany.tool_invocation_intent.v0`, and `epiphany.tool_invocation_receipt.v0`. Runtime-spine advertises these as the Epiphany-facing tool boundary. `epiphany-model-runtime` now materializes complete MCP-shaped model function calls as typed invocation intents, and `epiphany-tool-codex-mcp-spine` is the quarantined executing adapter: it consumes one typed invocation intent from the mixed runtime-spine CultCache store, executes the built-in read-only `epiphany_source` server for bounded file reads, git diff/show previews, and Hands receipt body readback, or calls user-declared Codex MCP through `codex-mcp`, then emits a typed invocation receipt. Raw MCP JSON remains protocol-edge cargo; Codex MCP is transport scaffolding, not Epiphany state, prompt, scheduler, or policy authority. Verification/Soul worker requests now advertise `mcp__epiphany_source__read_file`, `mcp__epiphany_source__git_show`, and `mcp__epiphany_source__read_hands_receipt`; OpenAI/Codex lowering uses `tool_choice=required` only before the first tool result after live dogfood proved `auto` can complete with zero tool calls and blanket `required` forces infinite follow-up tools; `epiphany-runtime-spine list-model-requests` prints tool counts/names; and follow-up turns are self-contained typed transcripts with original input, assistant `ToolCall`, and `ToolResult` because ChatGPT Codex rejects `previous_response_id`. Live dogfood proved the parser/tool-adapter path with one source-tool intent and one receipt; a stale active heartbeat binding from the earlier forced-tool loop still needs typed interruption or cleanup before the next Verification relaunch.
|
||||
- Native status now exposes that quarantined bridge spine without granting it authority. `runtime_spine_status` counts tool invocation intents, receipts, and pending calls; `runtime_tool_invocation_statuses` derives read-only intent/receipt status rows; `epiphany-runtime-spine status` reports the counts; and `epiphany-mvp-status --runtime-store <path>` renders the latest tool calls under `tools`. This is operator visibility only. The model-runtime feedback seam is also now typed: MCP-shaped model tool calls preserve the original provider `call_id` plus source model request id; `epiphany-model-runtime tool-followup` builds a provider-neutral follow-up `EpiphanyModelRequest` from completed typed tool receipts using the previous provider response id; and `epiphany-model-runtime tool-followup-turn` derives and runs that continuation through the selected provider in one runtime-owned operation. `epiphany-model-runtime run-worker --auto-tools --tool-adapter-bin <path>` now lets a launched worker automatically execute typed MCP intents through the quarantined Codex MCP adapter, feed receipts back through follow-up model turns, and only then parse/complete the worker result. Codex still executes the quarantined MCP edge; Epiphany owns the continuation request shape and invocation boundary.
|
||||
- The active foundation directive is now `notes/codex-starvation-and-cultnet-liberation-plan.md`. The previous Codex app-server control-plane rebuild made Epiphany less rotten inside Codex, but that is not the destination. Epiphany must become a native CultCache/CultMesh/CultNet runtime while remaining an honest modified Codex-derived backend for subscription auth/model use. Codex should remain relatively vanilla and keep doing Codex things, including useful app-server and streaming bridge affordances, but it must not own Epiphany state, processes, prompts, scheduler decisions, or policy. The bridge handles interop; Codex and Epiphany do not get to rummage around in each other's organs.
|
||||
- `notes/epiphany-cultmesh-dreaming-roadmap.md` is the new concrete design for distributed Epiphany dreaming. The invariant is hard: private state stays local; public dreams are separately authored typed documents distributed through CultMesh/CultNet; foreign dreams are thought weather until a reviewed local adoption receipt digests them. The first code slice should be dream schemas plus a local CultMesh-backed store, not public fanout.
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -182,8 +182,8 @@ accepted_design:
|
|||
- Limited native CRRC automation is now wired only at turn-complete safe boundaries: it can submit a compact operation when the read-only coordinator recommends `compactRehydrateReorient` or when a successful pre-compaction checkpoint intervention left a pending compact handoff for the completed turn, and it can launch the fixed `reorient-worker` when the coordinator recommends `launchReorientWorker`. It does not auto-launch modeling or verification, auto-accept findings, promote evidence, edit implementation code, or continue after reviewable semantic results; the rite may carry the stretcher, not declare the patient healed.
|
||||
- Pre-compaction checkpoint intervention is now wired at token-count boundaries: when a loaded Epiphany thread crosses the existing `shouldPrepareCompaction` pressure threshold during an active turn, the harness steers the active agent once for that turn with a bounded CRRC directive to bank scratch/checkpoint/map/evidence before compaction/reorientation. A successful steer marks a turn-scoped pending compact handoff consumed at clean turn completion; this is banking the fire before the dark, not semantic acceptance, broad scheduling, or automatic implementation continuation.
|
||||
- Native `epiphany-mvp-status` is the first dogfood operator view: it starts or reads a thread through app-server and renders scene, planning, pressure, reorient, jobs, role result read-backs, reorient result, CRRC recommendation, heartbeat, Face bubbles, and MVP role lanes as text or machine output without becoming a state store. The old Python status module has been cut; native Rust/CultCache/CultNet surfaces are the product path.
|
||||
- Native status now exposes the quarantined tool/MCP spine as operator-visible read-only state. Runtime-spine counts typed tool invocation intents, receipts, and pending calls; `runtime_tool_invocation_statuses` derives intent/receipt status rows; `epiphany-runtime-spine status` prints the counts; `epiphany-runtime-spine list-model-requests` prints request tool counts/names; and `epiphany-mvp-status --runtime-store <path>` renders a `tools` section without executing calls, accepting results, or letting Codex prompt machinery steer Epiphany agents. Verification/Soul workers now receive provider-neutral tool definitions on their model request for bounded read-only inspection: `mcp__epiphany_source__read_file`, `mcp__epiphany_source__git_show`, and `mcp__epiphany_source__read_hands_receipt`. The OpenAI/Codex spine lowers those definitions to Responses tools with `tool_choice=required` when tools are present, model tool calls become typed `epiphany.tool_invocation_intent.v0` documents, and the quarantined tool adapter resolves the built-in `epiphany_source` server directly under workspace-bounded read rules before falling back to Codex MCP. Soul should inspect source/artifacts/diffs/Hands receipt bodies through those tool receipts before returning `needs-evidence` for missing inspectability.
|
||||
- Model-tool feedback now has a typed continuation seam. `EpiphanyToolInvocationIntent` preserves the exact model `call_id` plus source model request id; provider-neutral and OpenAI request documents carry optional `previous_response_id`; the OpenAI Responses mapper emits that id as `previous_response_id`; `epiphany-model-runtime tool-followup` builds a provider-neutral follow-up request from typed tool receipts; `epiphany-model-runtime tool-followup-turn` derives and runs that continuation through the selected provider in one runtime-owned call; and `epiphany-model-runtime run-worker --auto-tools --tool-adapter-bin <path>` now loops tool execution plus follow-up model turns before completing the worker result.
|
||||
- Native status now exposes the quarantined tool/MCP spine as operator-visible read-only state. Runtime-spine counts typed tool invocation intents, receipts, and pending calls; `runtime_tool_invocation_statuses` derives intent/receipt status rows; `epiphany-runtime-spine status` prints the counts; `epiphany-runtime-spine list-model-requests` prints request tool counts/names; and `epiphany-mvp-status --runtime-store <path>` renders a `tools` section without executing calls, accepting results, or letting Codex prompt machinery steer Epiphany agents. Verification/Soul workers now receive provider-neutral tool definitions on their model request for bounded read-only inspection: `mcp__epiphany_source__read_file`, `mcp__epiphany_source__git_show`, and `mcp__epiphany_source__read_hands_receipt`. The OpenAI/Codex spine lowers those definitions to Responses tools with `tool_choice=required` only on an initial tool-bearing request that has no prior `ToolResult`; model `function_call` output items become typed `epiphany.tool_invocation_intent.v0` documents; and the quarantined tool adapter resolves the built-in `epiphany_source` server directly under workspace-bounded read rules before falling back to Codex MCP. Live dogfood proved this path by producing one source-tool intent and one receipt. Soul should inspect source/artifacts/diffs/Hands receipt bodies through those tool receipts before returning `needs-evidence` for missing inspectability.
|
||||
- Model-tool feedback now has a typed continuation seam. `EpiphanyToolInvocationIntent` preserves the exact model `call_id` plus source model request id; provider-neutral and OpenAI request documents can represent assistant `ToolCall` inputs and `ToolResult` inputs; and `epiphany-model-runtime tool-followup` builds a self-contained provider-neutral follow-up request from typed tool receipts by carrying original input, the assistant tool call, and the tool result instead of depending on provider-side `previous_response_id`. ChatGPT Codex rejected `previous_response_id`, so the live continuation invariant is explicit transcript over hidden provider memory. `epiphany-model-runtime tool-followup-turn` derives and runs that continuation through the selected provider in one runtime-owned call, and `epiphany-model-runtime run-worker --auto-tools --tool-adapter-bin <path>` loops tool execution plus follow-up model turns before completing the worker result.
|
||||
- The `roles` view lens is the harness-native role ownership surface: it projects implementation, Imagination/planning, modeling/checkpoint, verification/review, and reorientation lanes from authoritative typed state, bound jobs, pressure/reorient/CRRC, and worker result status without launching, scheduling, accepting, compacting, or mutating state.
|
||||
- `thread/epiphany/roleLaunch` and `thread/epiphany/roleResult` are the first explicit role-scoped specialist templates: Imagination/planning, modeling/checkpoint, and verification/review launch through fixed heartbeat-backed bindings with typed runtime-spine receipts and can be read back as reviewable findings from typed runtime-spine job results, while implementation stays owned by the main coding agent and reorientation stays on the CRRC-specific launch/result path.
|
||||
- `thread/epiphany/roleAccept` is the first review-gated role finding acceptance path: it accepts completed heartbeat-backed findings from typed runtime-spine results, accepts Imagination/planning findings only when they return a valid planning-only `statePatch` with draft Objective Draft review gates, accepts completed modeling/checkpoint findings only with a modeling-safe `statePatch`, accepts Research findings only with an Eyes-shaped evidence/scratch patch, and accepts Verification findings as receipt-only Soul verdict truth without granting statePatch authority. It builds accepted evidence/observation/receipt bundles through `epiphany-core` and rejects implementation, reorientation, job binding, objective adoption, or broad authority fields.
|
||||
|
|
|
|||
Reference in a new issue