pipeline_base
zocrates.agents.common.pipeline_base ¶
Shared scaffolding and scope management helpers for dynamic search workflows.
__all__
module-attribute
¶
__all__ = ['coerce_to_text', 'get_pipeline_interrupt_ids', 'recover_isolation_scope', 'ensure_isolation_scope', 'enqueue_isolation_scope_closing_event']
coerce_to_text ¶
Extract plain text string from string, Content, Part, dict, Event, or object.
Extracts text parts while strictly suppressing reasoning/thought parts (where
thought=True) and placing parts extraction ahead of .text to prevent
internal thought tokens or raw object reprs from leaking into user-facing answers.
Source code in zocrates/agents/common/pipeline_base.py
enqueue_isolation_scope_closing_event
async
¶
Emit a terminal finish_task event that closes ctx's isolation scope.
ADK's Runner._find_active_task_scope treats any non-empty
isolation_scope as an unclosed in-flight task agent awaiting user input
unless an event carrying a finish_task FunctionResponse (result
"Task completed." or "Task failed.") is recorded for that scope.
Stamping the pipeline's events with an isolation scope without explicit closure
causes ADK to tag subsequent user turns with the stale scope, causing the coordinator
(isolation_scope=None) to drop them. Emitting the closing event on the
invocation context lets Runner._find_active_task_scope recognize the scope as finished.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
The dynamically executed search pipeline context. |
required |
result
|
str
|
Terminal |
required |
default_author
|
str
|
Fallback author name if ctx.agent_name is unset. |
'search_pipeline_node'
|
Source code in zocrates/agents/common/pipeline_base.py
ensure_isolation_scope ¶
Recover and assign isolation scope to ctx and its invocation context if unset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
Workflow execution context. |
required |
prefixes
|
tuple[str, ...] | list[str] | str
|
Required tuple, list, or string of acceptable isolation scope prefix(es). |
required |
Source code in zocrates/agents/common/pipeline_base.py
get_pipeline_interrupt_ids ¶
Scan session events and ctx.resume_inputs to return set of all pipeline interrupt IDs.
Source code in zocrates/agents/common/pipeline_base.py
recover_isolation_scope ¶
Recover the search pipeline's isolation scope from snapshot or session events if unset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
Workflow execution context. |
required |
prefixes
|
tuple[str, ...] | list[str] | str
|
Required tuple, list, or string of acceptable isolation scope prefix(es)
(e.g. |
required |