Files
cleveractors-core/features/tool_agent_context_updates.feature
2026-05-27 21:41:03 +00:00

82 lines
3.5 KiB
Gherkin

Feature: Tool Agent and Application Context Updates
As a developer using CleverAgents
I want context updates from tools and streams to be properly captured
So that state is maintained throughout agent execution
Background:
Given I have a configured CleverAgents application
Scenario: Tool agent preserves context updates in Python code
Given I have a tool agent with Python code
When the code updates the context dictionary
Then the context changes should be saved globally
And the changes should be available after execution
Scenario: Tool agent handles None context gracefully
Given I have a tool agent with Python code
When the code is executed without providing context
Then the execution should complete without errors
And no context updates should be saved
Scenario: Global context updates are collected from tool executions
Given I have multiple tool agents
When each tool updates different context keys
Then all context updates should be collected in _CONTEXT_UPDATES
And the updates should be merged into the global context
@skip
Scenario: Application collects context updates in single-shot mode
Given I have an application with context-aware agents
When I run the application in single-shot mode
Then context updates from all streams should be collected
And the global context should be updated with all changes
Scenario: StreamMessage preserves context reference when copied
Given I have a StreamMessage with context metadata
When the message is copied with modifications
Then the context reference should be preserved
And modifications to the context should affect the original
Scenario: Stream router maintains global context reference
Given I have a stream router with global context
When messages flow through the router
Then the global context reference should be maintained
And context updates should be applied to the same object
Scenario: Context updates with writing_stage are properly filtered
Given I have context updates with different writing_stage values
When the application processes the updates
Then only non-intro writing_stage updates should be merged
And intro stage updates should be ignored
Scenario: Interactive session saves context with context manager
Given I start an interactive session with a context manager
When I send messages and receive responses
Then each exchange should be saved to the context
And the conversation history should be preserved
Scenario: Context manager handles concurrent updates
Given I have multiple agents updating context simultaneously
When they all complete their updates
Then all updates should be captured without data loss
And the final context should contain all changes
Scenario: Tool agent exec preserves context object reference
Given I have a tool agent with code that modifies context in place
When the code executes with exec()
Then the original context object should be modified
And no deep copying should occur
Scenario: Application handles empty context updates gracefully
Given I have agents that may or may not update context
When some agents return empty context updates
Then only non-empty updates should be processed
And the application should not crash
@skip
Scenario: Context updates from different stream types are captured
Given I have input, processing, and output streams
When each stream type updates context
Then updates from all stream types should be collected
And no updates should be lost