Skip to content

Commit c825f7b

Browse files
feat: agent make constructScratchPad async
1 parent dfffba1 commit c825f7b

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

langchain/src/agents/agent.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,9 @@ export abstract class Agent extends BaseSingleActionAgent {
262262
/**
263263
* Construct a scratchpad to let the agent continue its thought process
264264
*/
265-
constructScratchPad(steps: AgentStep[]): string | BaseChatMessage[] {
265+
async constructScratchPad(
266+
steps: AgentStep[]
267+
): Promise<string | BaseChatMessage[]> {
266268
return steps.reduce(
267269
(thoughts, { action, observation }) =>
268270
thoughts +

langchain/src/agents/chat/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ export class ChatAgent extends Agent {
6565
return new ChatAgentOutputParser();
6666
}
6767

68-
constructScratchPad(steps: AgentStep[]): string {
69-
const agentScratchpad = super.constructScratchPad(steps);
68+
async constructScratchPad(steps: AgentStep[]): Promise<string> {
69+
const agentScratchpad = await super.constructScratchPad(steps);
7070
if (agentScratchpad) {
7171
return `This was your previous work (but I haven't seen any of it! I only see what you return as final answer):\n${agentScratchpad}`;
7272
}

langchain/src/agents/chat_convo/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class ChatConversationalAgent extends Agent {
7575
}
7676
}
7777

78-
constructScratchPad(steps: AgentStep[]): BaseChatMessage[] {
78+
async constructScratchPad(steps: AgentStep[]): Promise<BaseChatMessage[]> {
7979
const thoughts: BaseChatMessage[] = [];
8080
for (const step of steps) {
8181
thoughts.push(new AIChatMessage(step.action.log));

0 commit comments

Comments
 (0)