SummaryExperienceSkillsProjectsFreight Data PlatformData engineeringFreightFlow DashboardBusiness intelligenceAI Agent AnalysisAI engineeringEducation
Learning Lab
AI Engineer ↗Data Engineer ↗Data Science ↗Problem Solving ↗Business Intelligence ↗Power BI monthly ↗English ↗Contact
◆ AI Agent Analysis
AI AGENT ARCHITECTURE / HARNESS ENGINEERING
Agent Harness EngineeringAgentic AIContext EngineeringDeterministic Guardrails

Engineering the harness behind an AI Analyst.

A domain-specific agent harness that any agent runtime with file and shell access can drive. It orchestrates specialized agents, invokes deterministic Python tools, persists structured state, enforces quality gates, and delivers evidence-grounded executive reports.

HOW THIS AGENT SYSTEM IS BUILT● ARCHITECTURE
Agent runtimeLLM + tool loop · tested on Claude Code + Antigravity
↓
Custom Analytics Agent Harness
OrchestrationCommands + routing
Agent Roles27 definitions
Skills & Tools8 skills + Python
Context & StateFile contracts + runs
GuardrailsFraming + QA gates
EvaluationsFault-injection tests
27Sub-agent definitions
8Reusable agent skills
5Primary workflows
3QA validation stages
18/18Checks passed per case
01 / What has been engineered

Agent = Model + Harness.

The project is best described as a custom analytics agent harness that is not tied to one runtime. That is a precise engineering claim: the model and runtime are external and replaceable; the business-specific operating system is authored in this repository.

PROVIDED BY THE HOST RUNTIME

Model + Agent Runtime

Underlying LLM reasoning, tool-invocation loop, agent execution environment and foundational permissions come from the host runtime. The tested build uses Claude Code; no Python file calls a model SDK.

Platform dependency: any LLM agent runtime that can read files, run shell commands and write files
BUILT IN THIS REPOSITORY

Domain-Specific Agent Harness

Task routing, role definitions, reusable skills, context rules, Python tools, file-based state, approval controls, QA gates and regression tests.

Engineering ownership: CLAUDE.md · .claude/ · runtime/ · scripts/
Terminology, without inflated claims. The consulting route is a sequential agentic workflow with LLM checkpoints; forecasting, regression and classification have separate role-based ML orchestration. The repository does not include a standalone agent runtime, MCP server, RAG system, model-neutral adapter layer or distributed tracing. Portability comes from the design instead, as the next block shows.
RUNTIME PORTABILITY

The harness does not care which agent runs it.

Everything that produces or checks a number lives in Python and JSON. The runtime only reads Markdown, runs shell commands and writes files, so moving to Codex CLI, Gemini CLI or a similar tool means changing how the workflow is started, not how it works.

0LLM SDK imports across 58 Python files
27agent files, none pinned to a model
Filesnot chat history carry each hand-off, under runs/{run_id}/
PORTABLE AS-IS
  • Python tools in scripts/, runtime/, skills/*/scripts/
  • File contracts validated against config/schemas/
  • Framing and QA gates, defect-injection tests
  • SKILL.md methods and agent role files (plain Markdown)
  • AGENTS.md entry point, read by most coding agents
THIN, RUNTIME-SPECIFIC LAYER
  • Folder convention .claude/ and CLAUDE.md
  • Slash commands such as /consult: elsewhere, the agent reads .claude/commands/consult.md and follows it
  • Parallel sub-agents in /forecast: elsewhere they run one after another with the same output
  • Permission settings in .claude/settings.json

Tested end to end on Claude Code and Google Antigravity. The runbook for other runtimes is in AGENTS.md → Running on Other Agent Runtimes.

02 / Custom harness modules

Six engineering layers around the model.

Each layer has a concrete implementation and an observable role in system reliability.

01↗

Agent Orchestration

Defined workflow routing and stages

Maps task intent into checkpoints, scripts and error exits. Agent execution itself comes from the host runtime.

.claude/commands/consult.mdscripts/run_consulting.py
Agent Orchestration · Agentic Workflow
02↗

Specialized Agents

Role-scoped execution and delegation

27 agent definitions across ML and reporting, with parallel model runners specified for ML workflows.

.claude/agents/forecasting/.claude/agents/regression/
Multi-Agent System · Sub-agents
03↗

Context Engineering

Keep analytical payloads out of chat

Central operating rules plus task-specific skills; working data and calculated facts move through files.

CLAUDE.md.claude/skills/*/SKILL.md
Context Engineering · Agent Skills
04↗

Tools & Execution

Use code for operations with exact outputs

Python tools handle profiling, calculation, schema checks and HTML/PPTX rendering.

runtime/.claude/skills/*/scripts/
Tool Use · Deterministic Execution
05↗

State & Contracts

Persist per-run handoff artifacts

Work files, status envelopes, manifests and report outputs isolate each run and facilitate review.

runs/{run_id}/config/schemas/
Persistent State · Structured Handoffs
06↗

Guardrails & Evaluations

Block invalid reports before release

Framing, report numerical checks, English-language scan and fault-injection tests.

validate_framing.pyqa_spec.pytest_consulting_gates.py
Deterministic Guardrails · Regression Tests
03 / Agent execution workflow

Reason, execute, validate. Repeat when required.

The /consult route alternates agent reasoning with deterministic computation and hard validation boundaries. The source directs the agent to correct framing/storyline files and rerun the relevant stages when a gate rejects them.

01PYTHON TOOL
Initialize + ProfileData schema, quality and cleaning assessment
data_profile.md · cleaning_assessment.json
02LLM AGENT
Frame the business questionBAD · MECE issue tree · ICE-ranked hypotheses
framing.json
03QA GATE
Validate the framingInvalid fields or incomplete problem → reject
validate_framing.py
04PYTHON TOOL
Execute deterministic analyticsKPIs · diagnostics · rate/mix decomposition
facts.json · report_spec.json
05LLM AGENT
Construct executive storylineSCQ · Minto Pyramid · recommendations
storyline.json
06QA GATE
Verify claims and narrative structureFact matching · chart rules · required recommendation fields
qa_spec.py
07PYTHON TOOL
Render and scan outputsHTML · PPTX · report language check
render_html.py · render_pptx.py · scan_language.py
Persistent handoff: runs/{run_id}/ → work/framing.json → work/facts.json → work/storyline.json → report/*
04 / Direct source evidence

Show the implementation, not the buzzwords.

Switch between verified source-code paths. These are concise maps of the repository, not simulated agent execution logs.

.claude/commands/consult.mdSOURCE EVIDENCE
1. run_consulting.py init → profiling
2. AGENT writes framing.json
3. run_consulting.py analyze → Framing Gate
4. Python computes facts.json
5. AGENT writes storyline.json
6. run_consulting.py report → QA + render
# Failure → fix the contract and rerun the gate
WHY IT MATTERS

Workflow router

Task routing and adaptive analytical checkpoints are encoded in a slash command; Python coordinates deterministic stages.

✓ Path verified in repository
.claude/agents/forecasting/ + ml-core/SOURCE EVIDENCE
forecasting/
├── prophet-agent.md
├── sarima-agent.md
├── lgbm-agent.md
├── baseline-agent.md
└── finalize-agent.md
ml-core/
├── model-selector.md
├── model-monitor.md
└── ml-report-builder.md
WHY IT MATTERS

Specialized subagents

Role definitions are plain Markdown that any runtime can load, while model-specific training and comparison use Python scripts.

✓ Path verified in repository
.claude/skills/SOURCE EVIDENCE
analytical-thinking/SKILL.md
consulting-analytical-report/SKILL.md
data-cleaning/SKILL.md
descriptive-diagnostics-analysis/SKILL.md
ml-toolkit/SKILL.md
ml-report/SKILL.md
analysis-report-html/SKILL.md
slide-deck-builder/SKILL.md
WHY IT MATTERS

Reusable domain capabilities

Skills package guidance and executable scripts. Skills are not separate deployed model services.

✓ Path verified in repository
runtime/contract.py + runs/{run_id}/SOURCE EVIDENCE
runs/{run_id}/
├── manifest.json
├── work/
│   ├── framing.json        # agent-generated
│   ├── facts.json          # Python-computed
│   ├── storyline.json      # agent-generated
│   └── report_spec.json
├── _status/{step}.json
└── report/{report.html,slidedeck.pptx}
WHY IT MATTERS

Run-scoped persistence

The system passes analytical artifacts through persisted files, avoiding conversational data transfer and reducing context pressure.

✓ Path verified in repository
validate_framing.py + qa_spec.pySOURCE EVIDENCE
Framing Gate
  required business context + hypotheses
  dataset column references

Report QA Gate
  slide structure + fact references
  numeric value matching (±0.1 rounding)

Language Scan
  Vietnamese-character check on English output
WHY IT MATTERS

Fail-fast validation

The gates verify specific mechanical constraints; the numeric matcher does not prove semantic correctness for every claim.

✓ Path verified in repository
tests/test_consulting_gates.pySOURCE EVIDENCE
E-Wallet       18 / 18 checks passed
TechWorld     18 / 18 checks passed

Examples of rejected defects:
• fabricated headline number
• unsupported chart type
• incomplete business framing
• missing recommendation owner
WHY IT MATTERS

Defect injection

Deterministic gate tests passed in both sample runs. No general end-to-end agent benchmark is claimed.

✓ Path verified in repository

All source paths in this section were checked against ai-analyst-system.zip.

05 / Keyword map

AI keywords mapped to actual code.

Each term is mapped to the code that implements it. Status labels separate what is implemented, what is partial and what is not present.

Agentic AI & Harness Engineering

10 terms
KeywordImplementationCode-level evidence
Agent Harness EngineeringImplementedCLAUDE.md + commands + scripts + gates
AI Agent OrchestrationImplemented/consult + ML workflow commands (Markdown)
Multi-Agent ArchitectureImplemented27 .claude/agents definitions
Agent SkillsImplemented8 filesystem-based SKILL.md folders
Context EngineeringImplementedCLAUDE.md + skills + file handoffs
Tool-Augmented ReasoningImplementedPython scripts invoked by agent workflow
Human-in-the-LoopImplemented--approve-cleaning gate
Persistent Agent StateImplementedruns/{run_id} + manifests
Structured HandoffsImplementedJSON contracts
Agentic WorkflowImplementedSequential consulting; parallel ML runners

Reliability & Evaluation

8 terms
KeywordImplementationCode-level evidence
Deterministic GuardrailsImplementedFraming/QA/Language validators
Fail-Fast ValidationImplementedexit on invalid framing/report
Evaluation-Driven DevelopmentPartialdefect injection; no behavioral eval suite
Evidence GroundingImplementedfacts.json used as report input
Numerical TraceabilityPartialvalue matching, not full semantic lineage
Agent ObservabilityPartialstep status and run logs, no spans
Human Approval CheckpointImplementeddata cleaning approval
Schema ValidationImplementedconfig/schemas + runtime/schema_guard.py

Applied AI Analytics & Consulting

8 terms
KeywordImplementationCode-level evidence
LLM–Python SeparationImplementedreasoning vs deterministic compute
Hypothesis-Driven AnalyticsImplementedBAD / MECE / ICE framing
Analytical DecompositionImplementedKPI and rate/mix
Executive StorytellingImplementedSCQ / Minto Pyramid
Automated Report GenerationImplementedHTML + PPTX
IBCS-Inspired ReportingPartialselected conventions, no certification
Forecasting / Classification / RegressionImplementedseparate ML workflows
MCP / RAG / Vector DatabaseNot presentnot in current repository
06 / Verified analytical outputs

When the harness meets real data.

Two sample-data investigations demonstrate consulting output and quality-gate behavior. These diagnostic findings are not measured post-deployment business improvements.

CASE 01 / E-WALLET14 SLIDES

Transaction Success Investigation

32,122 transactions · July–August 2023

−4.7 pp transaction success
  • Success rate: 91.7% → 86.9%.
  • Billing contributed 64.5% of total decline.
  • Auth accounted for 54.0% of incremental Billing failures.
CASE 02 / TECHWORLD13 SLIDES

Margin & Returns Diagnosis

2,008 order lines · Q1 2022

−15.3 pp February profit margin
  • Profit margin: 29.6% → 14.3% January to February.
  • Return rate: 3.5% → 27.9%.
  • Orders delivered after 7 days: 37.2% return rate versus 10.0%.
Test evidence: The repository’s consulting validation suite passed 18/18 checks per case, including injected numerical errors and structurally invalid outputs. This measures the gates under selected fixtures; it is not a full agent-run reliability metric.
07 / Technical writing

Engineering the Harness Behind an AI Analyst.

A case study for AI Engineer, Agent Engineer and Analytics Engineer readers. It leads with runtime boundaries, execution and reliability, then the consulting outcomes.

A model can write an executive summary in seconds. That tells us very little about whether the result is worth trusting. The difficult engineering work starts where the model meets data, tools, state, and validation.

I built an AI Analyst System around that boundary. It was built on Claude Code and also run end to end on Google Antigravity, but the analysis does not depend on it: the repository defines its own domain-specific harness: commands that route work, specialized agent instructions, reusable skills, Python tools, persistent file contracts, human checkpoints, and deterministic quality gates. The purpose is to turn an ambiguous business question into a report whose calculations can be inspected independently of the model that writes the narrative.

Model versus harness

The host runtime (Claude Code in the tested build) supplies the agent loop and tool execution. My repository supplies the analytics operating model. CLAUDE.md describes the non-negotiable rules, .claude/commands/ defines entry points, 27 agent definitions specialize reporting and ML tasks, and eight SKILL.md files package analytical methods and executable scripts.

This distinction matters: the project is a custom analytics harness built on an existing agent runtime. It does not implement a new general-purpose LLM runtime, and it does not need to claim one.

Context and state are engineering decisions

A recurring failure mode in analytical agents is passing large datasets, intermediate results, and chart payloads through chat history. In this system, durable state stays under runs/{run_id}/. A run has a manifest, step-status files, machine-readable work products, logs, and final deliverables. The agent writes framing.json and later storyline.json; Python computes the authoritative facts.json and drafts the report specification.

That file boundary reduces dependence on the conversation window and makes handoffs reviewable. It also creates a clear revision surface. A failed storyline can be corrected without rewriting the underlying calculations.

Orchestrate reasoning, execute calculations

The /consult route begins by profiling the input data and assessing cleaning requirements. The agent then applies a Business–Analytical–Data (BAD) framing process: define the decision and KPI, construct a MECE issue tree, identify hypotheses, rank them, and state what the dataset cannot answer. A validation script must approve that framing before downstream analysis.

Python handles KPI calculations, segment comparisons, hypothesis tests, and rate/mix decomposition. Once numerical facts have been written, the agent constructs a consulting storyline using SCQ and Minto Pyramid principles. The report specification passes another quality gate before HTML and PowerPoint rendering.

The repository also contains separate forecasting, regression, and classification commands with model-specific agents and scripts. In these ML workflows, multiple model runners are specified to work in parallel before winner selection and reporting.

Make failures visible

The harness uses three targeted checks. The framing validator rejects incomplete business context or invalid field references. A report validator checks structure, recommendation ownership, chart rules, and numerical expressions against the fact store with a rounding tolerance. The final language scan flags Vietnamese diacritics in English-language deliverables.

These checks are useful precisely because they have defined scope. Number matching is not yet full semantic provenance: a number may exist in the facts store but be used for the wrong segment or period. Nor does a language regex prove perfect Business English. Those limitations are part of the engineering backlog.

I reran the consulting gate tests for two cases; each passed 18 of 18 checks, including injected invalid claims and structural defects. That is regression evidence for the gates, not a benchmark of overall agent reliability.

What the system produced

On 32,122 e-wallet transactions, the analysis found the success rate falling from 91.7% to 86.9%; Billing contributed 64.5% of the aggregate deterioration. On 2,008 TechWorld order lines, it investigated a February profit-margin decline of 15.3 percentage points and separated contribution by category size from deterioration within categories. Both runs produced HTML reports and executive slide decks, with 14 slides for the wallet study and 13 for TechWorld.

These are diagnostic findings on sample datasets. They are not proof that a proposed intervention increased business revenue or reduced cost after deployment.

The engineering lesson

An analytics agent is only as dependable as its surrounding execution system. For this project, that means specialized tools, constrained handoffs, auditable run state, explicit approvals, and tests that make incorrect output fail visibly.

The next iteration will deepen semantic provenance, add richer run tracing and model-behavior evaluations, and strengthen isolation around execution. Those are the components that would move this specialized harness closer to a production-grade agent platform.

08 / Engineering candor

What is built — and what needs work.

What the repository implements today, and what is still missing.

IMPLEMENTED AND DEMONSTRATED

Current strengths

  • Agent command routing and specialized role definitions
  • Reusable filesystem-based skills and Python tools
  • Run-scoped artifacts and structured contracts
  • Human approval before applying cleaning changes
  • Fail-fast framing/report gates
  • Defect-injection checks demonstrated on two cases
  • HTML/PPTX executive artifact generation
NEXT ENGINEERING ITERATION

Production-readiness gaps

  • Claim-level semantic provenance by metric, period and segment
  • Structured traces, spans, latency and cost instrumentation
  • Scenario-level agent evaluations and tool-selection tests
  • Explicit sandboxing and least-privilege execution policies
  • Durable agent recovery/retry design beyond manual reruns
  • Automated cross-runtime regression runs (verified manually on Claude Code and Antigravity) and long-horizon agent state
  • Robust language detection and interactive consulting charts
09 / Research and terminology

Framework sources.

The terminology is aligned to current documentation from LangChain, Anthropic and OpenAI, plus the official IBCS standard. Sources define the patterns; source-code inspection determines what this project actually implements.