Analyzing Data Files
Analyzing Data Files
Mandatory delegation workflow for any .xlsx, .xls, .csv, or similar file. Never read or compute on these files directly — all access goes through subagents.
File uploaded → delegate to dataFile-context for a profile → summarize for the user in ≤8 lines → ask via question tool if they want to explore further → answer from the profile if possible, otherwise delegate again (and escalate to excel-reader only as last resort).
- Never read or calculate on the file yourself. No bash, no direct file reads. Only
dataFile-contextandexcel-readermay touch the data. - Pass the exact file path as received — don't rewrite, infer, or shorten it.
- Never invent figures. Every number given to the user must come from a subagent's response.
- Retain the step 1 profile in conversation context — it's the source for direct answers later.
- Limit re-delegation: max 1 re-delegation to
dataFile-contextand 1 escalation toexcel-readerper user question.
Progress:
- Step 1: Get general profile from
dataFile-context - Step 2: Ask user if they want to explore further
- Step 3: Answer from existing profile if possible
- Step 4: Re-delegate or escalate for missing information
- Final: Format response (result → details → caveats)
Step 1 — General Context (Always)
Delegate via task to dataFile-context:
Examine these files: <exact path(s)>.
Return the general profile: what the file is, structure by sheet, data quality, and key figures.
Do not modify anything. Be concise.
- Multiple files → send together in one delegation.
- If the user already asked a specific question, append
User question: ...to answer it in the same round trip. - Summarize for the user in your own words, ≤8 lines, no long tables pasted.
Step 2 — Offer Further Exploration (Always)
Use the question tool once (verify its schema first — don't invent parameters):
- Ask whether they want to explore further.
- Up to 3 suggestions derived from the profile (e.g., "Sales totals by city", "Check duplicates in column X") plus "No, that's enough".
- Allow free-text input.
- Don't ask this in plain text if the
questiontool is available.
If they decline, close with a brief line and stop.
Step 3 — Answer From Context When Possible
If the request's answer literally appears in the step 1 profile (a figure, column name, date range, null count), answer immediately without delegating.
Counts as "not in context" (go to Step 4 instead):
- Any new calculation (filter, group, sum, average) not already in the profile
- Columns, sheets, or rows not detailed in the profile
- Anything requiring verification or cross-referencing
When in doubt, go to Step 4. Never estimate or extrapolate from the profile.
Step 4 — Obtain Missing Information
4a. Re-delegate to dataFile-context with the specific question and known context so it doesn't repeat inspection:
File: <exact path>.
Known context: <relevant sheets/columns from the profile>.
Question: <exact user question>.
Do not repeat the general profile; perform only the necessary queries and return the figures.
Resume the prior subagent session if the task tool supports it.
4b. Escalate to excel-reader only if dataFile-context:
- Declares it cannot obtain the information or states a limitation,
- Fails or returns a tool error,
- Returns incomplete/inconsistent results,
- Or the question needs more than simple reading/aggregation (complex transforms, cross-sheet lookups).
File: <exact path>.
Question: <exact user question>.
Known context: <summarized profile>.
An attempt was made with dataFile-context and failed because: <reason>.
Answer only the question; do not repeat the general inspection.
If excel-reader also fails, tell the user honestly what couldn't be obtained and why. Never fabricate a result.
Skip steps 1–2. Go directly to step 3 or 4 using the existing profile. Only restart from step 1 if the file is new or changed.
Example 1:
Input: User uploads sales_2024.xlsx and asks "What's in this file?"
Output: Delegate to dataFile-context for profile → summarize in ≤8 lines ("3 sheets: Sales, Returns, Summary. 12,450 rows, no major nulls. Key figures: total revenue $2.3M...") → ask via question tool with suggestions like "Revenue by region", "Top 10 products", "No, that's enough".
Example 2:
Input: After profile, user asks "What's the total revenue for Q3 by region?"
Output: Not literally in profile (requires grouping/filtering) → re-delegate to dataFile-context with known context and exact question → return the figures returned by the subagent, not estimated.
Example 3:
Input: dataFile-context returns an error trying to cross-reference two sheets for a lookup.
Output: Escalate to excel-reader with the failure reason, file path, question, and context. Report result or honest failure to user.
- One delegation per task, bundling all files together.
- Include full context in delegation messages (path, question, known profile) to avoid wasted exploration steps.
- Prefer
dataFile-contextfirst;excel-readeris the expensive last resort. - Request aggregates, not raw rows, unless the user specifically needs row-level data.
- For large or multiple independent files, launch parallel
taskcalls todataFile-context. - Mention sensitive data (IDs, tax numbers, bank accounts, salaries) only if explicitly requested.
- Respond in the user's language.
- Direct result (lead with the figure/answer).
- Supporting details (brief table only if useful).
- Assumptions and data quality warnings, only if relevant.
- Reading or computing on the file directly instead of delegating.
- Rewriting or guessing the file path.
- Presenting a number not returned by a subagent.
- Re-delegating or escalating more than once per question.
- Asking the exploration question as plain text when the
questiontool is available. - Pasting long raw tables instead of a concise summary.
- Jumping straight to
excel-readerwithout tryingdataFile-contextfirst.