diff --git a/navi/core/agent.py b/navi/core/agent.py index 9e9b37b..894185b 100644 --- a/navi/core/agent.py +++ b/navi/core/agent.py @@ -520,9 +520,12 @@ content=( self._build_system_prompt(profile.system_prompt) + "\n\n---\n\n" - "[PLANNING] Before taking any actions, outline a concise numbered plan " - "for this request. Max 6 steps. Be specific — name which tools you will use " - "and what you expect to find. Do not execute anything yet." + "[PLANNING] Decide whether this request requires a multi-step plan.\n\n" + "If the request is a simple question, a conversation, or can be answered " + "in a single step without tools — respond with exactly: DIRECT\n\n" + "Otherwise outline a concise numbered plan (max 6 steps). " + "Be specific: name which tools you will use and what you expect to find. " + "Do not execute anything yet." ), ) planning_ctx: list[Message] = [planning_system] @@ -542,6 +545,15 @@ plan_text = (response.content or "").strip() if not plan_text: return [] + # Model signalled that no plan is needed — proceed directly + if plan_text.upper().startswith("DIRECT"): + log.debug("agent.planning_skipped", reason="direct") + return [] + # Sanity check: a real plan should have at least one numbered step + import re as _re + if not _re.search(r"^\s*\d+[\.\)]", plan_text, _re.MULTILINE): + log.debug("agent.planning_skipped", reason="no_numbered_steps") + return [] # Inject plan as assistant message so the main loop starts with it in context session.context.append(Message(role="assistant", content=plan_text)) log.debug("agent.plan_ready", length=len(plan_text))