General
PromptBeginner5 minmarkdown
<h1 align="center">
<a href="https://prompts.chat">
168
Rules for working with the agent core loop in selectools
Loading actions...
<a href="https://prompts.chat">
TypeScript and ESLint rules that MUST be followed when creating, modifying, or reviewing any file under apps/frontend/, including .ts, .tsx, .js, and .jsx files. Also apply when discussing frontend linting, type safety, or ESLint configuration.
risks
.content — final text response.trace — AgentTrace with typed timeline.reasoning — why agent chose tools.usage — aggregated token/cost statsWhen adding a feature that touches the agent loop:
agent/config.pyStepType to trace.py if recording trace stepsobserver.py if emitting lifecycle eventsif run_id: for consistency_notify_observers() helper, never call observer methods directlyFallbackProvider observer wiring uses threading.Lock + refcountbatch() uses ThreadPoolExecutor — each thread gets isolated historyabatch() uses asyncio.gather with copied agent instancesarun() on same agent shares _history (known limitation)response_msg.content or "" — providers can return None contentelif response_format is None: — prevent parser intercepting structured output_memory_add_many() — ensures on_memory_trim observers firerouting_only path must still fire on_iteration_end