mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-09-22 08:02:21 +02:00
fix(agent): close untrusted-context gate bypasses
This commit is contained in:
+12
-7
@@ -15,6 +15,7 @@ import json
|
||||
import logging
|
||||
|
||||
from src import bg_jobs
|
||||
from src.prompt_security import untrusted_context_message
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -25,6 +26,16 @@ POLL_INTERVAL_S = 5
|
||||
_FOLLOWUP_MAX_ROUNDS = 12
|
||||
|
||||
|
||||
def _background_result_message(rec):
|
||||
inject = (
|
||||
f"[Background job {rec['id']} finished]\n\n"
|
||||
f"{bg_jobs.result_text(rec)}\n\n"
|
||||
"Continue the task using this output. Don't repeat work that's already done. "
|
||||
"If the task is now complete, give the user the final result."
|
||||
)
|
||||
return untrusted_context_message("background job output", inject)
|
||||
|
||||
|
||||
async def _drain_agent(sess, messages):
|
||||
"""Run the agent loop headless against a session. Returns
|
||||
(final_prose, tool_events) — tool_events in the same shape the live chat
|
||||
@@ -101,14 +112,8 @@ async def _run_followup(rec: dict) -> bool:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
inject = (
|
||||
f"[Background job {rec['id']} finished]\n\n"
|
||||
f"{bg_jobs.result_text(rec)}\n\n"
|
||||
"Continue the task using this output. Don't repeat work that's already done. "
|
||||
"If the task is now complete, give the user the final result."
|
||||
)
|
||||
context = sess.get_context_messages()
|
||||
context.append({"role": "user", "content": inject})
|
||||
context.append(_background_result_message(rec))
|
||||
|
||||
full, tool_events = await _drain_agent(sess, context)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user