core.tools_consumer module
Tool-execution stream consumer for the dedicated tools service.
ToolExecConsumer mirrors core.stream_consumer.InboundStreamConsumer
— blocking XREADGROUP on sg:stream:tools under the sg:tools group,
an autoclaim sweep, and DLQ on repeated failure — but with two deliberate
differences:
No per-channel distributed lock. Tool execution must run fully in parallel and load-balance across
toolsinstances; user-visible message ordering is already enforced downstream by the gateway’s per-channel outbound lock.The injected
process_fnis expected to always reply (it pushes the result, or an error envelope, onto the caller’s reply stream) and to swallow tool-level exceptions. Only infrastructure failures propagate to the DLQ.
- core.tools_consumer.autoclaim_attempts_key(stream_name, group_name)
Return an attempts hash colocated with
stream_namein Cluster.An untagged Redis key hashes over its complete text, so wrapping that same text in braces selects the identical slot for the sidecar. If the stream already carries a non-empty hash tag, reuse it. The group digest keeps independent consumer groups on one stream from sharing retry counters.
- class core.tools_consumer.ToolExecConsumer(redis, consumer_name, process_fn, autoclaim_interval=30.0, autoclaim_min_idle=60000, *, stream_name='sg:stream:tools', group_name='sg:tools', require_durable_proof=False, delete_after_ack=False)
Bases:
objectConsumes tool-execution requests and dispatches them to process_fn.
- Parameters: