Problem
Currently using create_stream_with_auto_functions() which handles tool execution internally. This means we can only check for ctrl-c cancellation between tool batches, not during individual tool execution.
If Gemini requests multiple tools at once, pressing ctrl-c won't take effect until the entire batch completes.
Proposed Solution
Switch to manual function calling:
- Get function call requests from the stream
- Check cancellation before each individual tool call
- Execute tools ourselves with cancellation checks
- Send results back and continue
This would allow:
- Cancellation between individual tool calls (not just batches)
- Potentially aborting long-running tools mid-execution
- More control over tool execution flow
Current State
Basic ctrl-c handling is implemented using ctrlc crate + AtomicBool. It works for cancelling between batches, which is acceptable for now.
Problem
Currently using
create_stream_with_auto_functions()which handles tool execution internally. This means we can only check for ctrl-c cancellation between tool batches, not during individual tool execution.If Gemini requests multiple tools at once, pressing ctrl-c won't take effect until the entire batch completes.
Proposed Solution
Switch to manual function calling:
This would allow:
Current State
Basic ctrl-c handling is implemented using
ctrlccrate +AtomicBool. It works for cancelling between batches, which is acceptable for now.