Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
689 changes: 689 additions & 0 deletions ts/packages/agentServer/docs/async-clientio-design.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion ts/packages/agentServer/protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"tsc": "tsc -b"
},
"dependencies": {
"@typeagent/dispatcher-rpc": "workspace:*"
"@typeagent/dispatcher-rpc": "workspace:*",
"@typeagent/dispatcher-types": "workspace:*"
},
"devDependencies": {
"prettier": "^3.5.3",
Expand Down
7 changes: 7 additions & 0 deletions ts/packages/agentServer/protocol/src/protocol.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import type { PendingInteractionRequest } from "@typeagent/dispatcher-types";

export type DispatcherConnectOptions = {
filter?: boolean; // filter to message for own request. Default is false (no filtering)
clientType?: "shell" | "extension"; // identifies the connecting client type
Expand All @@ -18,6 +20,11 @@ export type JoinSessionResult = {
connectionId: string;
sessionId: string;
name: string;
/**
* Any pending interactions that are awaiting a client response.
* Sent on join so reconnecting clients can resume showing prompts.
*/
pendingInteractions?: PendingInteractionRequest[];
};

export type AgentServerInvokeFunctions = {
Expand Down
1 change: 1 addition & 0 deletions ts/packages/agentServer/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@typeagent/agent-server-protocol": "workspace:*",
"@typeagent/common-utils": "workspace:*",
"@typeagent/dispatcher-rpc": "workspace:*",
"@typeagent/dispatcher-types": "workspace:*",
"agent-dispatcher": "workspace:*",
"debug": "^4.4.0",
"default-agent-provider": "workspace:*",
Expand Down
2 changes: 2 additions & 0 deletions ts/packages/agentServer/server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ async function main() {
connectionId: result.connectionId,
sessionId,
name: result.name,
pendingInteractions:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't the display log replay sufficient?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, you could retrieve the last question asked from the previous message in display log. However, that's adding additional (potentially fragile) extraction logic on an ordered stream of events. In addition, potential future capabilities like interruptions or moving operations into the background could make extracting from display log much more difficult.

I think it's cleaner to just store pending interactions in this array (which is also already filtered for the specific connection). No need to run any parsing logic.

result.pendingInteractions ?? [],
};
} catch (e) {
channelProvider.deleteChannel(
Expand Down
10 changes: 9 additions & 1 deletion ts/packages/agentServer/server/src/sessionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
SessionInfo,
} from "@typeagent/agent-server-protocol";
import { ClientIO, Dispatcher, DispatcherOptions } from "agent-dispatcher";
import type { PendingInteractionRequest } from "@typeagent/dispatcher-types";
import {
createSharedDispatcher,
SharedDispatcher,
Expand Down Expand Up @@ -61,7 +62,12 @@ export type SessionManager = {
clientIO: ClientIO,
closeFn: () => void,
options?: DispatcherConnectOptions,
): Promise<{ dispatcher: Dispatcher; connectionId: string; name: string }>;
): Promise<{
dispatcher: Dispatcher;
connectionId: string;
name: string;
pendingInteractions: PendingInteractionRequest[];
}>;
leaveSession(sessionId: string, connectionId: string): Promise<void>;
listSessions(name?: string): SessionInfo[];
renameSession(sessionId: string, newName: string): Promise<void>;
Expand Down Expand Up @@ -316,6 +322,7 @@ export async function createSessionManager(
dispatcher: Dispatcher;
connectionId: string;
name: string;
pendingInteractions: PendingInteractionRequest[];
}> {
const record = sessions.get(sessionId);
if (record === undefined) {
Expand All @@ -340,6 +347,7 @@ export async function createSessionManager(
dispatcher,
connectionId: dispatcher.connectionId!,
name: record.name,
pendingInteractions: sharedDispatcher.getPendingInteractions(),
};
Comment thread
GeorgeNgMsft marked this conversation as resolved.
},

Expand Down
Loading
Loading