Close supervisor review loop and add handoff eval
This commit is contained in:
1 parent
c14adac162
commit
f0b00e5fd2
20 files changed
+2017
-129
No files matched your search
+24
-4
@@ -282,10 +282,11 @@ export class Agent {
|
||||
response: verified,
|
||||
skill,
|
||||
});
|
||||
const annotated = this.withHandoffMetadata(escalated, chain, depth);
|
||||
|
||||
const handoff = readHandoffRequest(escalated);
|
||||
const handoff = readHandoffRequest(annotated);
|
||||
if (!handoff) {
|
||||
return escalated;
|
||||
return annotated;
|
||||
}
|
||||
|
||||
const next = this.prepareHandoff({
|
||||
@@ -296,11 +297,15 @@ export class Agent {
|
||||
handoff,
|
||||
history,
|
||||
request,
|
||||
response: escalated,
|
||||
response: annotated,
|
||||
});
|
||||
|
||||
if (!next) {
|
||||
return this.makeSupervisorFallback(request, handoff.reason);
|
||||
return this.withHandoffMetadata(
|
||||
this.makeSupervisorFallback(request, handoff.reason),
|
||||
[...chain, "supervisor"],
|
||||
depth + 1,
|
||||
);
|
||||
}
|
||||
|
||||
return this.dispatch(next);
|
||||
@@ -308,6 +313,21 @@ export class Agent {
|
||||
);
|
||||
}
|
||||
|
||||
private withHandoffMetadata(
|
||||
response: AgentResponse,
|
||||
chain: string[],
|
||||
depth: number,
|
||||
): AgentResponse {
|
||||
return {
|
||||
...response,
|
||||
metadata: {
|
||||
...(response.metadata ?? {}),
|
||||
handoffChain: chain,
|
||||
handoffDepth: depth,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
private async runSkillOnce(input: {
|
||||
chain: string[];
|
||||
depth: number;
|
||||
|
||||
Reference in new issue
Block a user