INNER CODE UNIT · Python

pop_refine_context_for_thread

browser-use/bux · agent/agency_db.py:298

def pop_refine_context_for_thread(
    db: sqlite3.Connection, thread_id: int | None
) -> str | None:
    """For Edit (refine) flows: at the user's first reply in the worker
    topic, return the original card's context (title + description +
    prompt) as a plain-text block, AND atomically mark the suggestion as
    `refine_context_injected = 1` so subsequent calls return None.

    Replaces the file-based per-thread context cache the bot used to
    write to /var/lib/bux/agency-refine-context/<thread>.txt. The DB
    already holds the same content; querying it on the user's first
    reply is one SELECT + UPDATE and avoids a separate state surface.

    Returns None when:
      - thread isn't a worker topic for any suggestion
      - the suggestion isn't in 'differently' (Edit-tapped) status
      - context already injected on a prior call
    """

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…