Skip to content

Commit 51e4a8e

Browse files
authored
fix: display session ID after CLI invoke completes (#957)
* fix: display session ID after CLI invoke completes (closes #664) The streaming and non-streaming invoke responses include a session ID from the runtime, but the CLI paths discarded it. Now prints the session ID and a resume command hint after invoke output. * fix: include sessionId in AGUI protocol invoke result
1 parent 8613657 commit 51e4a8e

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

src/cli/commands/invoke/action.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ export async function handleInvoke(context: InvokeContext, options: InvokeOption
369369
agentName: agentSpec.name,
370370
targetName: selectedTargetName,
371371
response,
372+
sessionId: aguiResult.sessionId,
372373
logFilePath: logger.logFilePath,
373374
};
374375
} catch (err) {
@@ -415,6 +416,7 @@ export async function handleInvoke(context: InvokeContext, options: InvokeOption
415416
agentName: agentSpec.name,
416417
targetName: selectedTargetName,
417418
response: fullResponse,
419+
sessionId: result.sessionId,
418420
logFilePath: logger.logFilePath,
419421
};
420422
} catch (err) {
@@ -441,6 +443,7 @@ export async function handleInvoke(context: InvokeContext, options: InvokeOption
441443
agentName: agentSpec.name,
442444
targetName: selectedTargetName,
443445
response: response.content,
446+
sessionId: response.sessionId,
444447
logFilePath: logger.logFilePath,
445448
};
446449
}

src/cli/commands/invoke/command.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,13 @@ async function handleInvokeCLI(options: InvokeOptions): Promise<void> {
5656
if (options.json) {
5757
console.log(JSON.stringify(result));
5858
} else if (options.stream) {
59-
// Streaming already wrote to stdout, just show log path
59+
// Streaming already wrote to stdout, just show session and log path
60+
if (result.sessionId) {
61+
console.error(`\nSession: ${result.sessionId}`);
62+
console.error(`To resume: agentcore invoke --session-id ${result.sessionId}`);
63+
}
6064
if (result.logFilePath) {
61-
console.error(`\nLog: ${result.logFilePath}`);
65+
console.error(`Log: ${result.logFilePath}`);
6266
}
6367
} else {
6468
// Non-streaming, non-json: print provider info and response or error
@@ -67,8 +71,12 @@ async function handleInvokeCLI(options: InvokeOptions): Promise<void> {
6771
} else if (!result.success && result.error) {
6872
console.error(result.error);
6973
}
74+
if (result.sessionId) {
75+
console.error(`\nSession: ${result.sessionId}`);
76+
console.error(`To resume: agentcore invoke --session-id ${result.sessionId}`);
77+
}
7078
if (result.logFilePath) {
71-
console.error(`\nLog: ${result.logFilePath}`);
79+
console.error(`Log: ${result.logFilePath}`);
7280
}
7381
}
7482

src/cli/commands/invoke/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export interface InvokeResult {
2525
agentName?: string;
2626
targetName?: string;
2727
response?: string;
28+
sessionId?: string;
2829
error?: string;
2930
logFilePath?: string;
3031
}

0 commit comments

Comments
 (0)