mirror of https://github.com/buster-so/buster.git
Enhance agent streaming and logging in Analyst and Think and Prep steps
- Added consumption of text streams in both `runAnalystAgentStep` and `runThinkAndPrepAgentStep` to ensure continuous processing of agent responses. - Introduced detailed logging at various stages of the agent's execution to improve traceability and debugging. - These changes enhance the robustness of the agent workflow and provide better insights during execution.
This commit is contained in:
parent
855e7b1a55
commit
5d2631b848
|
@ -26,6 +26,15 @@ export async function runAnalystAgentStep({
|
||||||
const analystAgent = createAnalystAgent(options);
|
const analystAgent = createAnalystAgent(options);
|
||||||
|
|
||||||
const result = await analystAgent.stream(streamOptions);
|
const result = await analystAgent.stream(streamOptions);
|
||||||
|
|
||||||
|
// Consume the text stream to ensure the agent continues processing
|
||||||
|
if (result.textStream) {
|
||||||
|
for await (const _ of result.textStream) {
|
||||||
|
// We don't need to do anything with the text chunks,
|
||||||
|
// just consume them to keep the stream flowing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const response = await result.response;
|
const response = await result.response;
|
||||||
|
|
||||||
if (!response || !Array.isArray(response.messages)) {
|
if (!response || !Array.isArray(response.messages)) {
|
||||||
|
|
|
@ -23,11 +23,40 @@ export async function runThinkAndPrepAgentStep({
|
||||||
streamOptions,
|
streamOptions,
|
||||||
}: RunThinkAndPrepAgentStepInput): Promise<RunThinkAndPrepAgentStepOutput> {
|
}: RunThinkAndPrepAgentStepInput): Promise<RunThinkAndPrepAgentStepOutput> {
|
||||||
try {
|
try {
|
||||||
|
console.info('[runThinkAndPrepAgentStep] Starting agent stream', {
|
||||||
|
messageId: options?.messageId,
|
||||||
|
messageCount: streamOptions.messages.length,
|
||||||
|
});
|
||||||
|
|
||||||
const thinkAndPrepAgent = createThinkAndPrepAgent(options);
|
const thinkAndPrepAgent = createThinkAndPrepAgent(options);
|
||||||
|
|
||||||
const result = await thinkAndPrepAgent.stream(streamOptions);
|
const result = await thinkAndPrepAgent.stream(streamOptions);
|
||||||
|
|
||||||
|
console.info('[runThinkAndPrepAgentStep] Stream started, consuming stream', {
|
||||||
|
messageId: options?.messageId,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Consume the text stream to ensure the agent continues processing
|
||||||
|
if (result.textStream) {
|
||||||
|
for await (const _ of result.textStream) {
|
||||||
|
// We don't need to do anything with the text chunks,
|
||||||
|
// just consume them to keep the stream flowing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.info('[runThinkAndPrepAgentStep] Stream consumed, awaiting response', {
|
||||||
|
messageId: options?.messageId,
|
||||||
|
});
|
||||||
|
|
||||||
const response = await result.response;
|
const response = await result.response;
|
||||||
|
|
||||||
|
console.info('[runThinkAndPrepAgentStep] Response received', {
|
||||||
|
messageId: options?.messageId,
|
||||||
|
hasResponse: !!response,
|
||||||
|
hasMessages: !!response?.messages,
|
||||||
|
messageCount: response?.messages?.length,
|
||||||
|
});
|
||||||
|
|
||||||
if (!response || !Array.isArray(response.messages)) {
|
if (!response || !Array.isArray(response.messages)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'Think and prep agent returned an invalid response shape (missing messages array)'
|
'Think and prep agent returned an invalid response shape (missing messages array)'
|
||||||
|
|
Loading…
Reference in New Issue