Skip to content

Commit 10c43e9

Browse files
RafaelPogithub-actions[bot]
authored andcommitted
fix: add response_schema guidance to agent system prompt (#5078)
## Summary - Adds a dedicated **"Specifying the response schema"** subsection to both the MCP server instructions (`app.py`, used by Claude Desktop / claude.ai) and the everyrow-cc agent system prompt (`sdk_manager.py`) - Explicitly documents the `response_schema` parameter for Agent, Rank, and Single Agent operations with a concrete JSON Schema example - Calls out the anti-pattern of describing output fields only in the task prompt (which causes fallback to `DefaultAgentResponse` — a single `answer` string) ## Context Investigated session `a1f34a56` (G7 Average Temperatures) on Claude Desktop where Claude described three structured output fields (`avg_temp_celsius`, `temp_description`, `data_source`) in the task prompt but didn't pass a `response_schema`, so all rows got `{"answer": "..."}` with inconsistent formats. ## Test plan - [ ] Deploy MCP server to staging and run a multi-field agent operation via Claude Desktop — verify Claude passes `response_schema` with typed fields - [ ] Run same test via everyrow-cc to verify both code paths - [ ] Verify the schema example matches validation in `models.py:_validate_response_schema` 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Sourced from commit d003e1fa451df96c2decf8f0675d3132da3b160f
1 parent 354e73b commit 10c43e9

File tree

2 files changed

+34
-9
lines changed

2 files changed

+34
-9
lines changed

futuresearch-mcp/src/futuresearch_mcp/app.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,25 @@ async def no_auth_http_lifespan(_server: FastMCP):
9999
3. **Rank** — quantitative rating. Prefer an objective metric with units when possible. \
100100
Use a subjective 0-100 score only if necessary.
101101
4. **Agent** — open-ended web research when Classify, Rank, and Forecast don't fit. \
102-
Specify a response schema with descriptive column names (include units, e.g. \
103-
`population_millions`). Don't add reasoning/justification fields — users can \
104-
inspect the research behind each row.
102+
Pass `response_schema` for multi-field output (see below). Don't add reasoning/justification fields — \
103+
users can inspect the research behind each row.
105104
5. **Dedupe / Merge** — data consolidation.
106105
106+
## Specifying the response schema (Agent, Rank, Single Agent)
107+
108+
Agent, Rank, and Single Agent accept a `response_schema` parameter. If omitted, results \
109+
default to a single `{{"answer": string}}` field. Pass it whenever you need typed or \
110+
multi-field output. The schema is a JSON Schema object:
111+
112+
```json
113+
{{"type": "object", "properties": {{"avg_temp_celsius": {{"type": "number", "description": "Average annual temperature in Celsius"}}, "data_source": {{"type": "string", "description": "Source of the data"}}}}, "required": ["avg_temp_celsius", "data_source"]}}
114+
```
115+
116+
- Use descriptive field names with units (e.g. `population_millions`, `revenue_usd`)
117+
- Mark fields as `required` unless the data may legitimately be unavailable for some rows
118+
- Do NOT describe the desired output columns only in the `task` prompt — the schema \
119+
is what controls the output structure
120+
107121
## Workflow
108122
1. **Ingest data** — pass `data` (inline list of dicts) or an `artifact_id` \
109123
(from `futuresearch_upload_data` or `futuresearch_request_upload_url`) to any processing tool.

futuresearch-mcp/src/futuresearch_mcp/tools.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,12 @@ async def futuresearch_agent(
244244
requested research fields for each row. Agents run in parallel to save
245245
time and are optimized to find accurate answers at minimum cost.
246246
247+
`task` describes WHAT to research in natural language. `response_schema`
248+
defines the OUTPUT STRUCTURE as a JSON Schema. If omitted, results default
249+
to a single {"answer": string} field. Pass it whenever you need typed or
250+
multi-field output. Do NOT describe desired output columns only in `task`
251+
— the schema is what controls the output structure.
252+
247253
Examples:
248254
- "Find this company's latest funding round and lead investors"
249255
- "Research the CEO's background and previous companies"
@@ -323,6 +329,12 @@ async def futuresearch_single_agent(
323329
to research a single question. The agent can search the web, read pages, and
324330
return structured results.
325331
332+
`task` describes WHAT to research in natural language. `response_schema`
333+
defines the OUTPUT STRUCTURE as a JSON Schema. If omitted, results default
334+
to a single {"answer": string} field. Pass it whenever you need typed or
335+
multi-field output. Do NOT describe desired output columns only in `task`
336+
— the schema is what controls the output structure.
337+
326338
Examples:
327339
- "Find the current CEO of Apple and their background"
328340
- "Research the latest funding round for this company" (with input_data: {"company": "Stripe"})
@@ -401,6 +413,11 @@ async def futuresearch_rank(
401413
table. Conducts research, and can also apply judgment to the results if the
402414
criteria are qualitative.
403415
416+
`task` describes WHAT to score in natural language. `response_schema`
417+
optionally defines extra output columns as a JSON Schema. If omitted,
418+
only the score column is returned. Do NOT describe desired output columns
419+
only in `task` — the schema is what controls the output structure.
420+
404421
Examples:
405422
- "Estimate this drug's peak annual sales in billions of dollars"
406423
- "What is this country's 5-year GDP growth rate as a percentage?"
@@ -409,12 +426,6 @@ async def futuresearch_rank(
409426
This function submits the task and returns immediately with a task_id.
410427
411428
Then immediately follow the instructions in the response to monitor progress.
412-
413-
Args:
414-
params: RankInput
415-
416-
Returns:
417-
Success message containing task_id for monitoring progress
418429
"""
419430
logger.info(
420431
"futuresearch_rank: task=%.80s rows=%s",

0 commit comments

Comments
 (0)