Problem
Each runtime path prepares tools, transcript slices, and delivery channels differently, causing duplication and drift between the native loop and plugin harnesses before run_attempt.
Current state
- Tool assembly and message building scattered across
praisonaiagents/agent/chat_mixin.py, praisonaiagents/agent/chat_handler.py, and CLI backend execution branches in praisonaiagents/agent/agent.py.
- Handoff context policies in
praisonaiagents/agent/handoff.py mutate context ad hoc.
- No shared immutable turn plan object passed into runtime
run_turn.
Proposed design
- Add
PreparedTurnContext dataclass in praisonaiagents/runtime/turn_context.py capturing: resolved model_ref, AgentRuntimeProtocol instance, normalised tool schemas, transcript window, streaming/delivery handles, and session correlation ids.
- Build
PreparedTurnContext in one preflight step immediately before run_attempt (shared by all runtimes).
- Runtimes consume the plan read-only; mutations go through defined hooks only.
- Enables consistent metrics and tracing across harness types.
Acceptance criteria
Layer
Primary: core (praisonaiagents/runtime/turn_context.py)
Secondary: wrapper (CLI streaming delivery adapters)
3-way parity (Python / YAML / CLI)
| Surface |
Supported |
| Python |
yes — internal API |
| YAML |
no — internal normalisation only |
| CLI |
no — transparent to users |
Priority
P2
Related modules
praisonaiagents/agent/chat_mixin.py, praisonaiagents/agent/chat_handler.py, praisonaiagents/agent/unified_execution_mixin.py, praisonaiagents/streaming/
Related issues
Problem
Each runtime path prepares tools, transcript slices, and delivery channels differently, causing duplication and drift between the native loop and plugin harnesses before
run_attempt.Current state
praisonaiagents/agent/chat_mixin.py,praisonaiagents/agent/chat_handler.py, and CLI backend execution branches inpraisonaiagents/agent/agent.py.praisonaiagents/agent/handoff.pymutate context ad hoc.run_turn.Proposed design
PreparedTurnContextdataclass inpraisonaiagents/runtime/turn_context.pycapturing: resolvedmodel_ref,AgentRuntimeProtocolinstance, normalised tool schemas, transcript window, streaming/delivery handles, and session correlation ids.PreparedTurnContextin one preflight step immediately beforerun_attempt(shared by all runtimes).Acceptance criteria
praisonairuntime refactored to acceptPreparedTurnContextwithout behaviour regression in tests.Layer
Primary: core (
praisonaiagents/runtime/turn_context.py)Secondary: wrapper (CLI streaming delivery adapters)
3-way parity (Python / YAML / CLI)
Priority
P2
Related modules
praisonaiagents/agent/chat_mixin.py,praisonaiagents/agent/chat_handler.py,praisonaiagents/agent/unified_execution_mixin.py,praisonaiagents/streaming/Related issues