From ec1c12fa2e013de0ea455587b5fa3eb1afa8edb9 Mon Sep 17 00:00:00 2001 From: ciregenz Date: Wed, 1 Jul 2026 00:22:26 -0700 Subject: [PATCH] [eric] onboarding: fix payoff generation returning empty (max_tokens was 100, truncated the JSON mid-object); floor at 900 + forbid em-dashes/placeholders in the prompt --- backend/apps/agents/onboarding_suggest.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/apps/agents/onboarding_suggest.py b/backend/apps/agents/onboarding_suggest.py index 4177bf51..d5340912 100644 --- a/backend/apps/agents/onboarding_suggest.py +++ b/backend/apps/agents/onboarding_suggest.py @@ -24,6 +24,9 @@ from backend.apps.settings.settings import load_settings logger = logging.getLogger(__name__) SUGGEST_TIMEOUT_S = 20.0 +# aux_max_tokens_for is tuned for tiny labels (~100); this JSON (insight + task + 4 options) needs +# real room or it truncates mid-object and the parse fails. Floor at 900, keep the GPT-5 bump. +SUGGEST_MAX_TOKENS = 900 SYSTEM_PROMPT = ( "You set up the first screen a brand-new OpenSwarm user sees. OpenSwarm is NOT a chatbot: its AI " @@ -31,7 +34,8 @@ SYSTEM_PROMPT = ( "watch things and ping you. Given who the user is, write their landing content.\n" "RULES: plain language a non-dev instantly gets; NEVER invent specific facts about them (no 'your " "launch next week' you cannot know, keep the insight general and true); everything is an ACTION an " - "agent DOES (go, build, watch, chase, clean up, find), never 'ask me' or 'let's chat'.\n" + "agent DOES (go, build, watch, chase, clean up, find), never 'ask me' or 'let's chat'; no bracketed " + "placeholders like [framework]; never use em-dashes or en-dashes, use commas or periods.\n" "Return ONLY this JSON, nothing else:\n" '{"insight": "", ' '"task": " Optional[PayoffSuggestion]: async def run() -> None: async with client.messages.stream( model=aux_model, - max_tokens=aux_max_tokens_for(aux_model), + max_tokens=max(SUGGEST_MAX_TOKENS, aux_max_tokens_for(aux_model)), system=SYSTEM_PROMPT, messages=[{"role": "user", "content": user_turn}], extra_headers={"X-Openswarm-Task-Id": uuid4().hex},