feat: Allow AgentContext update consumer in BaseAgent and add beforeStream to TextAgentResponseHandler
This commit introduces the following changes: - **BaseAgent:** Added a mechanism to allow consumers to update the AgentContext after post-processing a split. This provides more flexibility for downstream components to react to the processed data. - **TextAgentResponseHandler:** Introduced a `beforeStream` consumer that allows updating the AgentContext before the stream begins. This enables pre-processing or initialization steps within the response handler. The constructor has been updated to accept this new consumer. Also fixed a bug where the chunkKey and updateKey were not being removed after processing. These changes enhance the extensibility and configurability of the agent processing pipeline.
This commit is contained in:
@@ -142,6 +142,9 @@ public interface BaseAgent {
|
||||
}
|
||||
|
||||
this.postProcess(split.context());
|
||||
if (split.context().getAgentContextUpdateConsumer() != null) {
|
||||
split.context().getAgentContextUpdateConsumer().accept(split.context());
|
||||
}
|
||||
|
||||
finishedSplits.add(split);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user