From 521f81a9691273bf70d8bb4cb50f6aaff44886e0 Mon Sep 17 00:00:00 2001 From: tomi Date: Fri, 13 Nov 2026 22:56:01 +0100 Subject: [PATCH 1/2] fix(goal): simplify finish schema for MCP adapters (cherry picked from commit 3438f1158dbad8bdd55de27b8fd7b2c1a05f2cb7) --- src/tools/goal.rs | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/tools/goal.rs b/src/tools/goal.rs index 3227e06b..3af4f80c 100644 --- a/src/tools/goal.rs +++ b/src/tools/goal.rs @@ -186,11 +186,12 @@ impl Tool for GoalTool { "writeOnly": true } }, + // Avoid status-dependent anyOf on this tool's wire schema. + // Some MCP adapters normalize its conditional branches into + // an untyped map and silently drop the summary/reason fields, + // leaving an otherwise valid goal_finish call impossible. + // finish_report checks the status-specific requirement below. "required": ["expectedRevision", "status", "nextSteps"], - "anyOf": [ - {"properties": {"status": {"const": "completed"}}, "required": ["summary"]}, - {"properties": {"status": {"const": "blocked"}}, "required": ["reason"]} - ], "additionalProperties": false }), } @@ -604,6 +605,27 @@ mod tests { GoalTool::Set.input_schema()["properties"]["markdown"]["writeOnly"], true ); + assert!(schema.get("anyOf").is_none()); + assert_eq!(schema["properties"]["summary"]["type"], "string"); + assert_eq!(schema["properties"]["reason"]["type"], "string"); + let valid: FinishArgs = serde_json::from_value(json!({ + "expectedRevision":1, + "status":"completed", + "summary":"Completed the independent read-only audit with evidence", + "nextSteps":"None" + })) + .expect("flat finish schema should preserve the summary"); + assert!(matches!( + finish_report(&valid), + Ok(GoalFinish::Completed { .. }) + )); + let missing: FinishArgs = serde_json::from_value(json!({ + "expectedRevision":1, + "status":"completed", + "nextSteps":"None" + })) + .expect("summary remains optional on the wire but required by runtime validation"); + assert!(finish_report(&missing).is_err()); let goal = GoalRecord { revision: 1, From d0910fa14377ed00128b633593434bc95eb0c04c Mon Sep 17 00:00:00 2001 From: tomi Date: Sat, 14 Nov 2026 07:04:01 +0100 Subject: [PATCH 2/2] fix(ci): simplify existing goal retry eligibility predicate --- src/agent_automation/store.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/agent_automation/store.rs b/src/agent_automation/store.rs index a00f59b3..7eee3834 100644 --- a/src/agent_automation/store.rs +++ b/src/agent_automation/store.rs @@ -420,7 +420,7 @@ impl AutomationTaskState { return false; }; let action = &self.action; - if goal.status != GoalStatus::Active + !(goal.status != GoalStatus::Active || action.goal_revision != Some(goal.revision) || action.id.is_none() || action.status == AutomationActionStatus::Idle @@ -437,11 +437,7 @@ impl AutomationTaskState { || action.kind == Some(AutomationActionKind::OfflineCombined) && action.status != AutomationActionStatus::Cancelled && action.send_accepted == Some(true) - && action.messages_fenced) - { - return false; - } - true + && action.messages_fenced)) } pub(crate) fn goal_retry_at_ms(&self) -> Option {