Core LLM layer resends the full conversation every turn — no opt-in server-side conversation reuse (`previous_response_id`) on the Responses API
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 39/100
Direzione di ricerca
Start by reading _build_responses_params and _build_messages in src/praisonai-agents/praisonaiagents/llm/llm.py, then trace the sync, sync-stream, and async Responses API call paths. The work needs to track response IDs across turns and handle opt-in configuration, provider support, and invalidated history. It is done when enabled sessions reuse server-side state with safe fallbacks, while the default behavior remains stateless.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
On the OpenAI Responses API path, every agent turn resends the entire conversation as input. There is no option to reuse the provider's own server-side conversation state (previous_response_id + store=True), so input tokens and request latency grow with the length of a session.
This is most costly for the SDK's long-lived surfaces — a gateway/bot channel session can run for hundreds of turns, and each turn re-uploads the whole (or compacted) history. Local context compaction shrinks the payload but still resends it on every call. A provider that already persists prior turns is being asked to re-ingest them each time.
Adding an opt-in server-side conversation mode (default behaviour unchanged) would cut input tokens to the per-turn delta, lower latency, and keep the SDK's long-running sessions efficient — without affecting providers or configurations that don't support it.
Current behaviour
_build_responses_params always flattens the full message list into input with no continuation handle:
# src/praisonai-agents/praisonaiagents/llm/llm.py (_build_responses_params)
# system message → instructions
# remaining messages → input (list of role/content items)
# ...
params: Dict[str, Any] = {"model": self._resolve_openai_compatible_model()}
# ... builds instructions + input_items from EVERY message, every call ...
# no `previous_response_id`, no `store`
The message list itself is rebuilt in full each turn:
# src/praisonai-agents/praisonaiagents/llm/llm.py
def _build_messages(self, prompt, system_prompt=None, chat_history=None, ...):
# assembles system_prompt + full chat_history + prompt every turn
The Responses API is actively used on three call sites (_build_responses_params is invoked from the sync loop, sync-stream loop, and async loop), confirming this is the live path for OpenAI reasoning / gpt-5 / o-series models:
# src/praisonai-agents/praisonaiagents/llm/llm.py
if self._supports_responses_api():
responses_params = self._build_responses_params(...)
resp = self._call_responses_api(**responses_params)
Grep confirms there is no previous_response_id, store=True, or conversation-continuation handle anywhere under praisonaiagents/llm/.
Note: this is distinct from the already-addressed gateway inbound /v1/responses HTTP surface (persistence/idempotency, e.g. #5335, #5726). This issue is about the agent's outbound calls to the model provider.
Desired behaviour
An opt-in mode where, on providers that persist server-side conversation state, the SDK:
- sends
store=Trueand captures the returnedresponse.id, - on the next turn sends only the new input items plus
previous_response_id=<last id>, instead of the full history, - transparently falls back to full-history resend when the provider/model doesn't support it, when state is lost, or when local history is mutated (compaction,
/compress, history edits) in a way that invalidates the server-side chain.
Default remains the current stateless, fully-portable behaviour. The feature engages only when explicitly enabled and the provider supports it.
Layer placement
- Primary layer: core (
src/praisonai-agents/praisonaiagents/llm/) - Why not core: n/a — the resend happens in core's provider call construction (
_build_responses_params), and the continuation handle must be tracked across turns inside the core LLM/session loop. This is the only place with the request/response pair. - Why not wrapper: the wrapper can't inject
previous_response_idwithout reaching into core's per-turn request building and response handling; it only exposes config. - Why not tools: this is model-call plumbing, not an agent-callable integration.
- Why not plugins: it isn't a lifecycle hook/guardrail; it changes how the core LLM request is constructed and how response ids are threaded between turns.
- Secondary touch (optional):
ExecutionConfigflag (e.g.server_side_conversation), plus a wrapper CLI/YAML surface so it's configurable the 3 standard ways. - 3-way surface (CLI + YAML + Python): yes — Python (
ExecutionConfig/Agent(...)), YAML (agents.yaml), CLI flag.
Proposed approach
- Extension point:
ExecutionConfigoption + a small continuation-state field threaded through the LLM turn loop; gated behind aself._supports_responses_api()-style capability probe. - Minimal API sketch:
# opt-in; default False preserves today's stateless behaviour
agent = Agent(
name="assistant",
llm="gpt-5",
server_side_conversation=True, # or via ExecutionConfig / YAML / CLI
)
Resolution sketch
# Before (today) — src/praisonai-agents/praisonaiagents/llm/llm.py
def _build_responses_params(self, messages, tools=None, temperature=None, **kwargs):
params = {"model": self._resolve_openai_compatible_model()}
instructions, input_items = self._split_system_and_input(messages) # ALL messages, every turn
params["input"] = input_items
return params
# After (proposed) — opt-in, backward compatible
def _build_responses_params(self, messages, tools=None, temperature=None, **kwargs):
params = {"model": self._resolve_openai_compatible_model()}
if self._server_side_conversation_active(): # opt-in AND provider supports it
prev_id = self._last_response_id # captured from previous turn
if prev_id and not self._history_was_mutated(): # compaction/edit invalidates the chain
params["store"] = True
params["previous_response_id"] = prev_id
params["input"] = self._delta_input_items(messages) # only NEW items since prev_id
return params
params["store"] = True # start/refresh the chain
instructions, input_items = self._split_system_and_input(messages) # full resend (fallback/default)
params["input"] = input_items
return params
# and, after each call, capture the id to chain the next turn:
# self._last_response_id = resp.id
Severity
Medium — not a correctness bug; it's an opt-in cost/latency optimisation. But it compounds on the SDK's primary long-running workload (gateway channel sessions), where per-turn input currently grows O(turns); server-side chaining makes each request O(delta).
Validation
- Read
src/praisonai-agents/praisonaiagents/llm/llm.py_build_responses_paramsin full: it maps the complete message list toinputon every call, with nostore/previous_response_id. - Read
_build_messages: fullsystem + chat_history + promptreassembled each turn. - Confirmed the Responses API path is live (3 invocation sites: sync, sync-stream, async) behind
_supports_responses_api(). - Grep across
praisonaiagents/llm/forprevious_response_id/store=True/ conversation-continuation: no matches. - Checked existing issues: related closed items (#5335, #5726) concern the gateway's inbound
/v1/responsesHTTP surface, not the agent's outbound provider calls — no duplicate.
- Lingua principale
- Python
- Stelle
- 9.3k
- Fork
- 1.5k
- Merge medio
- 1g 5h
- PR unite (30g)
- 520
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di MervinPraison/PraisonAI
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
MervinPraison/PraisonAI#6710 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
claude
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
MervinPraison/PraisonAI#6707 ·
I maintainer di solito rispondono entro 1 giorno
-
bug claude
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
MervinPraison/PraisonAI#6671 ·
I maintainer di solito rispondono entro 1 giorno
-
Compaction budget regression fixture remains below budget with accurate tokenizationForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
MervinPraison/PraisonAI#5418 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
bug claude documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
MervinPraison/PraisonAI#5341 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di MervinPraison/PraisonAI
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 2 giorni
-
[Bug]: LANGSMITH_SAMPLING_RATE ignores fractional values (isdigit check), traces 100% of requestsAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
platform/backend tests
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Significant-Gravitas/AutoGPT#17100 ·
I maintainer di solito rispondono entro 1 giorno
-
bug good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 61/100
scverse/infercnvpy#238 ·
I maintainer di solito rispondono entro 1 giorno