perf: preserve conversation prefixes across agent turns
This commit is contained in:
1 parent
1440a1f508
commit
f1bb5d02aa
19 files changed
+552
-205
No files matched your search
@@ -330,6 +330,8 @@ class OperatorNode:
|
||||
image_scrub_depth_relaxed=getattr(cfg, "image_scrub_depth_relaxed", None),
|
||||
context_budget_tokens=getattr(cfg, "context_budget_tokens", None),
|
||||
start_ratio=getattr(cfg, "start_ratio", None),
|
||||
soft_ratio=getattr(cfg, "soft_ratio", 0.7),
|
||||
hard_ratio=getattr(cfg, "hard_ratio", 0.9),
|
||||
session_start=session_start if isinstance(session_start, (int, float)) else None,
|
||||
)
|
||||
# L2/L3 chunk compression (M3) rides the same flag; without a
|
||||
@@ -392,7 +394,7 @@ class OperatorNode:
|
||||
"""
|
||||
from langchain_core.messages import HumanMessage
|
||||
|
||||
from artemis.memory.transcript import mark_ephemeral
|
||||
from artemis.memory.transcript import OBSERVATION_SCOPE_RULE, mark_ephemeral
|
||||
|
||||
ledger = self._ensure_transcript_ledger(state)
|
||||
|
||||
@@ -407,6 +409,7 @@ class OperatorNode:
|
||||
if getattr(self.ctx, "plugins", None):
|
||||
prefix.append(self.ctx.plugins.prompt())
|
||||
prefix.append(static_text)
|
||||
prefix.append(OBSERVATION_SCOPE_RULE)
|
||||
ledger.set_static_prefix([SystemMessage(content="\n".join(prefix))])
|
||||
|
||||
# 2. F region cold start: an empty ledger over an existing step record
|
||||
@@ -496,7 +499,7 @@ class OperatorNode:
|
||||
tail_content.append(part)
|
||||
tail = HumanMessage(content=tail_content)
|
||||
# Per-turn notices (reminders, hints, guidance, incident blocks) are
|
||||
# deleted by the scrub edge once the turn leaves the recent window.
|
||||
# deleted only when phase compaction rewrites the recent window.
|
||||
if builder.ephemeral_indices:
|
||||
mark_ephemeral(tail, builder.ephemeral_indices)
|
||||
|
||||
@@ -635,12 +638,8 @@ class OperatorNode:
|
||||
transcript_ledger.record_prompt_tokens(
|
||||
usage.get("prompt_tokens"), messages=current_messages
|
||||
)
|
||||
elif hasattr(transcript_ledger, "record_prompt_tokens"):
|
||||
# No usage metadata from the provider: record an estimate so
|
||||
# the start gate and thresholds still see a context base.
|
||||
from artemis.memory.transcript import estimate_prompt_tokens
|
||||
|
||||
transcript_ledger.record_prompt_tokens(estimate_prompt_tokens(current_messages))
|
||||
# Without provider usage the ledger estimates the complete next
|
||||
# prompt at render time; do not label that estimate as a measurement.
|
||||
|
||||
if response.content:
|
||||
if isinstance(response.content, str):
|
||||
|
||||
Reference in new issue
Block a user