fix: intermediate text as standalone messages, preserve progress
Add 'intermediate' phase for assistant text between tool calls. These are sent as separate Discord messages without finalizing or disrupting the active progress message.
This commit is contained in:
@@ -32,7 +32,7 @@ interface ContainerInput {
|
|||||||
|
|
||||||
interface ContainerOutput {
|
interface ContainerOutput {
|
||||||
status: 'success' | 'error';
|
status: 'success' | 'error';
|
||||||
phase?: 'progress' | 'final' | 'tool-activity';
|
phase?: 'progress' | 'final' | 'tool-activity' | 'intermediate';
|
||||||
result: string | null;
|
result: string | null;
|
||||||
newSessionId?: string;
|
newSessionId?: string;
|
||||||
error?: string;
|
error?: string;
|
||||||
@@ -546,6 +546,7 @@ async function runQuery(
|
|||||||
if (message.type !== 'assistant' && pendingProgressText) {
|
if (message.type !== 'assistant' && pendingProgressText) {
|
||||||
writeOutput({
|
writeOutput({
|
||||||
status: 'success',
|
status: 'success',
|
||||||
|
phase: 'intermediate',
|
||||||
result: pendingProgressText,
|
result: pendingProgressText,
|
||||||
newSessionId,
|
newSessionId,
|
||||||
});
|
});
|
||||||
@@ -625,7 +626,7 @@ async function runQuery(
|
|||||||
log(`Discarding pending progress (matches result)`);
|
log(`Discarding pending progress (matches result)`);
|
||||||
pendingProgressText = null;
|
pendingProgressText = null;
|
||||||
} else if (pendingProgressText) {
|
} else if (pendingProgressText) {
|
||||||
writeOutput({ status: 'success', result: pendingProgressText, newSessionId });
|
writeOutput({ status: 'success', phase: 'intermediate', result: pendingProgressText, newSessionId });
|
||||||
pendingProgressText = null;
|
pendingProgressText = null;
|
||||||
}
|
}
|
||||||
log(`Result #${resultCount}: subtype=${message.subtype}${textResult ? ` text=${textResult.slice(0, 200)}` : ''}`);
|
log(`Result #${resultCount}: subtype=${message.subtype}${textResult ? ` text=${textResult.slice(0, 200)}` : ''}`);
|
||||||
@@ -700,6 +701,7 @@ async function runQuery(
|
|||||||
if (pendingProgressText) {
|
if (pendingProgressText) {
|
||||||
writeOutput({
|
writeOutput({
|
||||||
status: 'success',
|
status: 'success',
|
||||||
|
phase: 'intermediate',
|
||||||
result: pendingProgressText,
|
result: pendingProgressText,
|
||||||
newSessionId,
|
newSessionId,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ export interface AgentInput {
|
|||||||
export interface AgentOutput {
|
export interface AgentOutput {
|
||||||
status: 'success' | 'error';
|
status: 'success' | 'error';
|
||||||
result: string | null;
|
result: string | null;
|
||||||
phase?: 'progress' | 'final' | 'tool-activity';
|
phase?: 'progress' | 'final' | 'tool-activity' | 'intermediate';
|
||||||
newSessionId?: string;
|
newSessionId?: string;
|
||||||
error?: string;
|
error?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,6 +105,17 @@ export class MessageTurnController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (result.phase === 'intermediate') {
|
||||||
|
// Send as standalone message without touching progress state
|
||||||
|
if (text) {
|
||||||
|
await this.options.channel.sendMessage(this.options.chatJid, text);
|
||||||
|
}
|
||||||
|
if (!this.poisonedSessionDetected) {
|
||||||
|
this.resetIdleTimer();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (result.phase === 'tool-activity') {
|
if (result.phase === 'tool-activity') {
|
||||||
// Ensure a progress message exists for tool activity sub-lines
|
// Ensure a progress message exists for tool activity sub-lines
|
||||||
if (!this.progressMessageId && !this.progressCreating) {
|
if (!this.progressMessageId && !this.progressCreating) {
|
||||||
|
|||||||
Reference in New Issue
Block a user