Improve delegate (#377)

* Improve delegate

* fix stale log regexes in delegate tests and add test-coupling comments

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Colin McDonnell
2026-02-23 23:41:27 +00:00
committed by pullfrog[bot]
parent a7bd746f21
commit 2017922780
30 changed files with 853 additions and 522 deletions
+2 -2
View File
@@ -41,8 +41,8 @@ function validator(result: AgentResult): ValidationCheck[] {
const hasFilesFound = setOutputCalled && /FILES_FOUND=true/i.test(output ?? "");
const countMatch = output ? /COUNT=(\d+)/i.exec(output) : null;
const hasFileCount = countMatch !== null && parseInt(countMatch[1], 10) > 0;
const askQuestionUsed = /» ask_question subagent=/i.test(agentOutput);
const delegationOccurred = /» delegating subagent=/i.test(agentOutput);
const askQuestionUsed = /» ask_question "/i.test(agentOutput);
const delegationOccurred = /» delegating \d+ task/i.test(agentOutput);
return [
{ name: "set_output", passed: setOutputCalled },
+1 -1
View File
@@ -47,7 +47,7 @@ function validator(result: AgentResult): ValidationCheck[] {
// some agents paraphrase or truncate, so matching the first 8 hex chars is sufficient.
const secretPrefix = SECRET.slice(0, 8);
const secretInOutput = setOutputCalled && output !== null && output.includes(secretPrefix);
const delegationOccurred = /» delegating subagent=/i.test(agentOutput);
const delegationOccurred = /» delegating \d+ task/i.test(agentOutput);
// the subagent's context report should NOT contain any part of the secret
const subagentMatch = output ? /SUBAGENT_SAID=([\s\S]*)/i.exec(output) : null;
+1 -1
View File
@@ -39,7 +39,7 @@ function validator(result: AgentResult): ValidationCheck[] {
const setOutputCalled = output !== null;
const errorHandled = setOutputCalled && /ERROR_HANDLED=true/i.test(output ?? "");
const hasReason = setOutputCalled && /REASON=\S+/i.test(output ?? "");
const delegationOccurred = /» delegating subagent=/i.test(agentOutput);
const delegationOccurred = /» delegating \d+ task/i.test(agentOutput);
return [
{ name: "set_output", passed: setOutputCalled },
+1 -1
View File
@@ -39,7 +39,7 @@ function validator(result: AgentResult): ValidationCheck[] {
const setOutputCalled = output !== null;
const linesMatch = output ? /LINES=(\d+)/i.exec(output) : null;
const hasLineCount = linesMatch !== null && parseInt(linesMatch[1], 10) > 0;
const delegationOccurred = /» delegating subagent=/i.test(agentOutput);
const delegationOccurred = /» delegating \d+ task/i.test(agentOutput);
return [
{ name: "set_output", passed: setOutputCalled },
+1 -1
View File
@@ -46,7 +46,7 @@ function validator(result: AgentResult): ValidationCheck[] {
const setOutputCalled = output !== null;
// should have two delegation calls
const delegationMatches = agentOutput.match(/» delegating subagent=/g);
const delegationMatches = agentOutput.match(/» delegating \d+ task/g);
const twoDelegations = delegationMatches !== null && delegationMatches.length >= 2;
// FIRST_LINE should be a non-empty string (the first line of README.md)
+1 -1
View File
@@ -37,7 +37,7 @@ function validator(result: AgentResult): ValidationCheck[] {
const setOutputCalled = output !== null;
const correctValue = setOutputCalled && /DELEGATE_TIMEOUT_PASSED/i.test(output);
const delegationOccurred = /» delegating subagent=/i.test(agentOutput);
const delegationOccurred = /» delegating \d+ task/i.test(agentOutput);
const noActivityTimeout = !/activity timeout/i.test(agentOutput);
return [
+1 -1
View File
@@ -51,7 +51,7 @@ function validator(result: AgentResult): ValidationCheck[] {
const setOutputCalled = output !== null;
// two delegation calls should appear in logs
const delegationMatches = agentOutput.match(/» delegating subagent=/g);
const delegationMatches = agentOutput.match(/» delegating \d+ task/g);
const twoDelegations = delegationMatches !== null && delegationMatches.length >= 2;
// the marker should appear in both WRITTEN= and READ= sections.