refactor(subagent): rename relayed to omitClosingText
This commit is contained in:
1 parent
92edf5bb0d
commit
99980c3a2e
3 files changed
+14
-16
No files matched your search
@@ -72,14 +72,12 @@ interface ActivationBase {
|
||||
*/
|
||||
announced: boolean
|
||||
/**
|
||||
* Whether this child's last action before its closing text was a message to
|
||||
* its direct parent: the only tool call of its step, with no input claimed
|
||||
* and no tool call started since.
|
||||
* Its settlement notice then omits the closing message, which restates that
|
||||
* message.
|
||||
* Whether this child's settlement notice omits its closing text: true while
|
||||
* the child's last action was a message to its direct parent, as the only
|
||||
* tool call of its step, with no input claimed and no tool call logged since.
|
||||
*/
|
||||
relayed: boolean
|
||||
/** Tool calls the child's current step logged, which decides {@link relayed}. */
|
||||
omitClosingText: boolean
|
||||
/** Tool calls the child's current step logged, which decides {@link omitClosingText}. */
|
||||
stepToolCalls: number
|
||||
}
|
||||
|
||||
|
||||
@@ -133,15 +133,15 @@ function settlementSummary(childId: SessionId, stopReason: SubagentResult['stopR
|
||||
* @param childId - durable child session id named in the notice.
|
||||
* @param terminal - recorded terminal state for the settled Activation.
|
||||
* @param continuable - whether the child can accept another task.
|
||||
* @param relayed - whether the child's last action before its closing text was a message to the parent,
|
||||
* which omits the closing message.
|
||||
* @param omitClosingText - replace the closing text with a note that the child's
|
||||
* last message to the parent already carries it.
|
||||
* @returns the durable user-message representation delivered to the parent.
|
||||
*/
|
||||
export function createSettlementMessage(
|
||||
childId: SessionId,
|
||||
terminal: SubagentResult,
|
||||
continuable = true,
|
||||
relayed = false,
|
||||
omitClosingText = false,
|
||||
): ReturnType<typeof createUserMessage> {
|
||||
const summary = settlementSummary(childId, terminal.stopReason, continuable)
|
||||
// Parent providers receive this notice as a user message and may reject
|
||||
@@ -153,7 +153,7 @@ export function createSettlementMessage(
|
||||
return createUserMessage({
|
||||
content: [
|
||||
{ type: 'text' as const, text: summary },
|
||||
...relayed
|
||||
...omitClosingText
|
||||
? [{ type: 'text' as const, text: 'It sent you a message just before finishing, so its closing message is omitted.' }]
|
||||
: closingText.length === 0
|
||||
? [{ type: 'text' as const, text: 'It left no closing message.' }]
|
||||
|
||||
@@ -934,7 +934,7 @@ export class SubagentManager {
|
||||
ownedChildren: new Set(),
|
||||
observer,
|
||||
announced: false,
|
||||
relayed: false,
|
||||
omitClosingText: false,
|
||||
stepToolCalls: 0,
|
||||
}
|
||||
void activation.result.promise.catch(() => undefined)
|
||||
@@ -951,7 +951,7 @@ export class SubagentManager {
|
||||
activation.handle.agent.ctx.on('agent/inbox/claimed', () => {
|
||||
// Claimed input means the closing text may report work the child's
|
||||
// last message to its parent did not.
|
||||
activation.relayed = false
|
||||
activation.omitClosingText = false
|
||||
wakeSettlement()
|
||||
})
|
||||
activation.handle.agent.ctx.on('agent/inbox/discarded', wakeSettlement)
|
||||
@@ -961,7 +961,7 @@ export class SubagentManager {
|
||||
if (event.type === 'step/start') activation.stepToolCalls = 0
|
||||
else if (event.type === 'tool/call') {
|
||||
activation.stepToolCalls += 1
|
||||
activation.relayed = false
|
||||
activation.omitClosingText = false
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1202,7 +1202,7 @@ export class SubagentManager {
|
||||
const parent = this.ctx.agents.get(activation.parent.id)
|
||||
if (parent !== activation.parent) return
|
||||
const message = createSettlementMessage(
|
||||
activation.childId, terminal, activationAgent(activation) !== undefined, activation.relayed,
|
||||
activation.childId, terminal, activationAgent(activation) !== undefined, activation.omitClosingText,
|
||||
)
|
||||
if (this.closingTeardownFor(parent) !== undefined) {
|
||||
parent.inject(message)
|
||||
@@ -1315,7 +1315,7 @@ export class SubagentManager {
|
||||
}
|
||||
const message = createAgentMessage(sender, content)
|
||||
this.sendAgentMessage(parent, message)
|
||||
activation.relayed = activation.stepToolCalls <= 1
|
||||
activation.omitClosingText = activation.stepToolCalls <= 1
|
||||
return message.id
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user