From b5003a8a62593649f83b2dca49c3b193f84f818c Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 11 Aug 2026 08:20:32 +0200 Subject: [PATCH] Remove duplicate worker schema prompt --- epiphany-openai-runtime/src/lib.rs | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/epiphany-openai-runtime/src/lib.rs b/epiphany-openai-runtime/src/lib.rs index e5a70e55..01c97051 100644 --- a/epiphany-openai-runtime/src/lib.rs +++ b/epiphany-openai-runtime/src/lib.rs @@ -590,8 +590,7 @@ pub fn build_worker_model_request( ); let launch_document_text = serde_json::to_string_pretty(&launch_document) .context("failed to render worker launch document for model input")?; - let mut instructions = - worker_instructions(launch_request, &launch_document, &output_schema_json); + let mut instructions = worker_instructions(launch_request, &launch_document); if launch_request.binding_id == epiphany_core::EPIPHANY_VERIFICATION_ROLE_BINDING_ID { instructions.push_str("\n\nTool mandate: before returning `needs-evidence` because source files, artifact directories, command artifacts, commit diffs, Hands receipt bodies, or resident grant lifecycle are not inspectable, call the governed read-only tools available on this request. Use `mcp__epiphany_source__read_file` for cited source/artifact files, `mcp__epiphany_source__directory_inventory` for bounded workspace directory counts and bytes, `mcp__epiphany_source__git_show` for commit diffs, `mcp__epiphany_source__read_hands_receipt` for Hands patch/command/commit receipts, and `mcp__epiphany_state__resident_grant_lifecycle` for exact or bounded recent grant-owned lifecycle state. Directory totals are authoritative only when the tool reports `complete=true`. Grant launchability is authoritative only from the typed state projection, never artifact names or acknowledgement presence. If a tool fails, cite that failed tool result and the exact remaining blocker."); } else if launch_request.binding_id == epiphany_core::EPIPHANY_RESEARCH_ROLE_BINDING_ID { @@ -1364,7 +1363,6 @@ fn provider_matches_request(selected: &str, requested: &str) -> bool { fn worker_instructions( launch_request: &EpiphanyRuntimeWorkerLaunchRequest, launch_document: &EpiphanyWorkerLaunchDocument, - output_schema_json: &str, ) -> String { let output_contract = worker_output_contract_text(launch_document); let dynamic_context = launch_document @@ -1372,8 +1370,8 @@ fn worker_instructions( .map(|context| format!("\n\n{context}")) .unwrap_or_default(); format!( - "{}{}\n\nReturn only one JSON object. No Markdown, no commentary.\n\n{}\n\nOutput schema JSON:\n```json\n{}\n```", - launch_request.instruction, dynamic_context, output_contract, output_schema_json + "{}{}\n\nReturn only one JSON object through the declared response format. Emit every object key at most once. No Markdown, no commentary.\n\n{}", + launch_request.instruction, dynamic_context, output_contract ) } @@ -2104,6 +2102,15 @@ mod tests { Ok(()) } + #[test] + fn role_ingress_rejects_duplicate_top_level_fields() { + let error = parse_assistant_json::( + r#"{"roleId":"modeling","verdict":"checkpoint-ready","summary":"mapped","nextSafeMove":"review","checkpointSummary":"first","checkpointSummary":"second"}"#, + ) + .expect_err("duplicate typed fields must remain ambiguous and fail closed"); + assert!(format!("{error:#}").contains("duplicate field `checkpointSummary`")); + } + #[test] fn verification_ingress_preserves_exact_request_and_route_binding() -> Result<()> { let parsed = parse_assistant_json::( @@ -2839,8 +2846,11 @@ mod tests { assert!(output_schema.contains("\"const\": \"frontier-modeling-request-1\"")); assert!(output_schema.contains("\"const\": \"incorporate_frontier_verdict\"")); assert!(!output_schema.contains("\"const\": \"evolution\"")); - assert!(model_request.instructions.contains("Output schema JSON")); - assert!(model_request.instructions.contains("\"repoModelPatch\"")); + assert!(!model_request.instructions.contains("Output schema JSON")); + assert!(!model_request.instructions.contains("\"repoModelPatch\"")); + assert!(model_request + .instructions + .contains("Emit every object key at most once")); assert_eq!(model_request.reasoning_effort.as_deref(), Some("low")); assert_eq!(model_request.reasoning_summary.as_deref(), Some("concise")); assert!(model_request