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:
extio-de
2025-07-02 21:45:44 +02:00
parent c5e2ace604
commit 7cf067400b
2 changed files with 15 additions and 4 deletions

View File

@@ -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);
}