Skip to content

Commit 775b901

Browse files
jackwildmangithub-actions[bot]
authored andcommitted
fix: teach single_agent to use return_table + response_schema for lists (#5113)
## Summary - Adds defense-in-depth guidance across all 4 layers the agent reads so it knows to set `return_table=True` + `response_schema` when using `single_agent` for list generation - Without these params, lists get crammed into a single `{"answer": string}` text blob instead of a structured multi-row table ### Files changed 1. **sdk_manager.py** (system prompt) — bolded instruction on the single_agent bullet 2. **app.py** (MCP instructions) — appended list generation guidance 3. **tools.py** (tool docstring) — added "For list generation" paragraph + concrete example 4. **models.py** (field descriptions) — made `response_schema` and `return_table` descriptions prescriptive ## Test plan - [x] Agent unit tests pass (135/135) - [x] MCP server tests pass (356/356) - [ ] Manual: ask everyrow-cc "Find 15 AI startups in healthcare" — verify it sets `return_table=True` and provides a schema - [ ] Regression: single-value queries ("What is the capital of France?") still work without return_table 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Sourced from commit 5a16b968f1b794df8a329e59f84f9c75db682070
1 parent aabab0a commit 775b901

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

futuresearch-mcp/src/futuresearch_mcp/app.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ async def no_auth_http_lifespan(_server: FastMCP):
8989
2. **URLs** — upload from a URL or Google Sheet via `futuresearch_upload_data`.
9090
3. **From memory** — if you know a good starting list, generate it as inline `data`.
9191
4. **single_agent** — dispatch a research agent to find or build a list. \
92-
Works well but slow (3-5 min), so prefer the options above.
92+
Works well but slow (3-5 min), so prefer the options above. \
93+
When generating a list, always set `return_table=True` and provide a `response_schema` \
94+
defining the fields per item — otherwise results come back as a single text string.
9395
9496
## Choosing the right operation
9597

futuresearch-mcp/src/futuresearch_mcp/models.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,9 @@ class SingleAgentInput(BaseModel):
556556
)
557557
response_schema: dict[str, Any] | None = Field(
558558
default=None,
559-
description="Optional JSON schema for the agent response.",
559+
description="JSON schema for the agent response. Required when return_table=True "
560+
"to define the fields for each item in the list. If omitted, results default to "
561+
'a single {"answer": string} field.',
560562
)
561563
effort_level: EffortLevel | None = Field(
562564
default=EffortLevel.MEDIUM,
@@ -581,7 +583,9 @@ class SingleAgentInput(BaseModel):
581583
)
582584
return_table: bool = Field(
583585
default=False,
584-
description="If true, return results as a multi-row table (one row per item). Use when the task produces a list of items (e.g. 'list all X'). If false (default), return a single result row.",
586+
description="MUST be true when the task asks for a list of items (e.g. 'find 15 startups', "
587+
"'list all X'). Always pair with response_schema to define the fields per item. "
588+
"If false (default), returns a single result row.",
585589
)
586590
session_id: str | None = Field(
587591
default=None,

futuresearch-mcp/src/futuresearch_mcp/tools.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,17 @@ async def futuresearch_single_agent(
336336
multi-field output. Do NOT describe desired output columns only in `task`
337337
— the schema is what controls the output structure.
338338
339+
**For list generation:** When the task asks for a list of items, set
340+
`return_table=True` and provide a `response_schema` defining the fields
341+
for each item. This returns a multi-row table instead of a single text blob.
342+
339343
Examples:
340344
- "Find the current CEO of Apple and their background"
341345
- "Research the latest funding round for this company" (with input_data: {"company": "Stripe"})
342346
- "What are the pricing tiers for this product?" (with input_data: {"product": "Snowflake"})
347+
- "Find 15 AI startups in healthcare" (with return_table=True and response_schema:
348+
{"type": "object", "properties": {"name": {"type": "string"}, "description": {"type": "string"},
349+
"url": {"type": "string"}}, "required": ["name", "description"]})
343350
344351
This function submits the task and returns immediately with a task_id.
345352

0 commit comments

Comments
 (0)