MWMS Agent Loop Context Schema

System: MWMS
Document Type: Schema Standard
Status: Draft For MCR
Authority: HeadOffice
Applies To: All MWMS Brains, AI Employees, Agent Loops, Deep Search Workflows, Research Workflows, Affiliate Evaluation, Ads Review, Content Workflows, Experimentation Brain, HeadOffice Intelligence, Future Client Facing AI Systems
Primary Location: MCR
Future Operational Destination: mwmsbrain.site, mwmsheadofficebrain.site, AI Employee Dashboards, Future Agent Control Dashboards
Parent Page: HeadOffice
Source Of Truth: MCR
Related Frameworks: MWMS Agent Loop Control Framework, MWMS Next Action Picker Standard, MWMS AI Observability Metadata Standard, MWMS AI Employee Evaluation Scorecard Standard, MWMS Deep Search Quality And Observability Framework
Course Source: Matt Pocock AIhero Build DeepSearch In TypeScript
Absorption Status: Approved For Integration


Purpose

The purpose of this schema standard is to define the shared context container used by MWMS AI Employee agent loops.

An agent loop context is the structured working memory that allows an AI Employee to understand:

  • what it is trying to achieve
  • which Brain owns the work
  • what step it is on
  • what actions have already happened
  • what evidence has been collected
  • what sources have been inspected
  • what tools have failed
  • what limits have been reached
  • whether it should continue, answer, route, escalate, park, or stop

This standard ensures AI Employees do not lose the original goal, repeat work, ignore evidence, exceed limits, or make decisions without the correct operational context.


Scope

This standard applies to any MWMS workflow where an AI Employee performs multi-step reasoning, search, tool use, routing, source inspection, or decision-making.

This includes:

  • Deep Search workflows
  • Research Brain source investigation
  • Affiliate Brain offer evaluation
  • Ads Brain compliance review
  • Content Brain research workflows
  • Newsletter Intelligence processing
  • HeadOffice signal routing
  • Experimentation Brain analysis
  • Data Brain validation
  • Finance Brain cost review
  • Brain Room AI support
  • Dev Console AI support
  • future client-facing AIBS agents
  • future autonomous AI Employees
  • future workflows using search, scraping, databases, tools, action pickers, or escalation logic

This standard does not define exact database tables or code implementation.

It defines the conceptual schema that future implementation should follow.


Core Rule

Every agent loop must carry a shared context object that preserves the workflow goal, current state, action history, evidence state, limits, and final outcome.

The MWMS rule is:

No AI Employee loop should operate from memory alone, prompt text alone, or hidden SDK state alone.

The loop context is the system memory for the workflow.


Definition Of Agent Loop Context

Agent Loop Context is the structured state object used during an AI Employee workflow.

It contains:

  • the original request
  • the workflow goal
  • the current step
  • the allowed actions
  • the action history
  • the evidence collected
  • the tools used
  • the source history
  • the database records used
  • the current confidence state
  • the cost and latency state
  • the stop conditions
  • the review and escalation state
  • the final output state

The context object should be available to the Next Action Picker, action executors, final answer generator, observability system, evaluation system, and HeadOffice review layer.


Why MWMS Needs Agent Loop Context

Without a structured context container, AI Employees may:

  • lose the original user request
  • answer the wrong question
  • repeat the same search
  • inspect the same source twice
  • forget failed tools
  • ignore source conflicts
  • exceed cost limits
  • exceed step limits
  • answer before enough evidence exists
  • miss escalation conditions
  • route to the wrong Brain
  • create orphaned outputs
  • become impossible to debug
  • become impossible to evaluate

A strong context schema prevents agent drift.


Relationship To Agent Loop Control

The MWMS Agent Loop Control Framework defines the full controlled agent loop.

This schema defines the state object used inside that loop.

The normal relationship is:

Agent Loop Control Framework
→ defines how the loop works

Next Action Picker Standard
→ defines how the next action is selected

Agent Loop Context Schema
→ defines what information the loop carries

AI Observability Metadata Standard
→ defines what gets logged and traced

AI Employee Evaluation Scorecard Standard
→ defines how loop quality is judged


Relationship To Next Action Picker

The Next Action Picker depends on the context schema.

The picker cannot choose correctly unless it can see:

  • original request
  • workflow goal
  • current step
  • previous actions
  • evidence collected
  • failed actions
  • limits
  • allowed actions
  • risk state
  • stop conditions
  • review requirements

If context is weak, the picker will be weak.

A strong Next Action Picker requires a strong context object.


Context Schema Categories

MWMS Agent Loop Context is divided into twelve categories:

  1. Identity Context
  2. Workflow Context
  3. Goal Context
  4. Parameter Context
  5. Action Context
  6. Search And Source Context
  7. Evidence Context
  8. Database Context
  9. Tool And Failure Context
  10. Cost And Performance Context
  11. Review And Decision Context
  12. Final Output And Kaizen Context

Each category exists to keep the AI Employee aligned, observable, and governable.


1. Identity Context

Identity Context defines who or what owns and triggered the workflow.

Recommended fields:

FieldDescription
context_idUnique context record ID
loop_idRelated agent loop ID
trace_idRelated observability trace ID
created_atContext creation time
updated_atLast context update time
user_idUser ID if available
user_nameHuman operator name
user_roleRole of requester or operator
request_originWhere the request came from
brain_nameBrain responsible for the workflow
brain_siteSite where the workflow occurs
ai_employee_nameAI Employee handling the work
ai_employee_roleRole of the AI Employee
environmentLocal, test, staging, production

Rule

Every context object must identify the responsible Brain or system.

If no Brain is known, the context should be marked:

brain_name: Unclassified

and routed to HeadOffice review.


2. Workflow Context

Workflow Context defines the type and state of the work being performed.

Recommended fields:

FieldDescription
workflow_typeCategory of workflow
workflow_nameSpecific workflow name
task_idRelated task ID
thread_idRelated conversation thread
parent_record_idParent offer, source, experiment, newsletter, report, or campaign
run_idUnique workflow run ID
workflow_stageCurrent workflow stage
statusPending, running, completed, failed, parked, routed, escalated
priorityLow, medium, high, urgent
urgencyMonitor, test, act now, emergency
risk_levelLow, medium, high
trigger_typeManual, scheduled, event based, routed, automated

Workflow Type Examples

  • Deep Search research
  • source investigation
  • offer evaluation
  • newsletter extraction
  • newsletter routing
  • compliance review
  • campaign analysis
  • content research
  • experiment analysis
  • finance review
  • Brain Room reply
  • Dev Console support
  • HeadOffice decision support

Rule

Every context object must define the workflow type.

If the workflow type is unclear, the system should use:

workflow_type: Unclassified AI Workflow

and route to review.


3. Goal Context

Goal Context preserves the original purpose of the workflow.

Recommended fields:

FieldDescription
original_requestThe original user or system request
workflow_goalThe operational goal of the workflow
expected_output_typeAnswer, report, decision, task, route, scorecard, source record
success_criteriaWhat good output looks like
required_evidence_levelNone, light, medium, high
required_freshness_levelHistorical, evergreen, recent, current
required_confidence_thresholdMinimum confidence needed
user_constraintsAny constraints from the user
business_constraintsCost, compliance, timing, scope, Brain boundary
completion_definitionWhat must be true for the loop to finish

Rule

Every action, picker decision, and final answer must remain tied to the original request and workflow goal.

If the context loses the goal, the loop should stop or escalate.


4. Parameter Context

Parameter Context defines the limits and configuration for the loop.

Recommended fields:

FieldDescription
current_stepCurrent loop step number
max_stepsMaximum allowed loop steps
max_searchesMaximum search actions
max_sources_to_inspectMaximum source inspections
max_database_queriesMaximum database queries
max_retriesMaximum retries
max_costMaximum estimated cost
max_latency_msMaximum time allowed
max_tokensToken budget
allowed_actionsList of approved actions
allowed_toolsList of approved tools
stop_conditionsList of stop rules
escalation_conditionsList of escalation rules
fallback_actionWhat to do if loop cannot complete
model_policyWhich model or model class can be used

Rule

Important loop behaviour must be controlled by explicit parameters, not hidden prompt assumptions.


5. Action Context

Action Context records what the loop has already done.

Recommended fields:

FieldDescription
action_historyList of previous action records
previous_action_typeMost recent action type
previous_action_statusSuccess, failed, skipped, partial
selected_next_actionCurrent selected next action
selected_action_reasonWhy the picker selected it
duplicate_action_detectedYes or no
action_count_by_typeCounts by action type
action_picker_confidenceConfidence in selected action
invalid_action_attemptedYes or no
action_evaluation_resultResult of evaluating action choice

Recommended Action History Item

{
"step": 1,
"action_type": "search",
"reason": "Need current source evidence before answering",
"target": "current Google Ads policy for health claims",
"status": "completed",
"tool_used": "web_search",
"output_summary": "Found official Google policy page and two secondary sources",
"cost_estimate": 0.02,
"latency_ms": 1200,
"used_in_final_output": true,
"failure_reason": ""
}

Rule

No loop should proceed without knowing what actions have already been attempted.


6. Search And Source Context

Search And Source Context tracks external information retrieval.

Recommended fields:

FieldDescription
search_historyList of search queries performed
search_countNumber of searches completed
search_providerTool or provider used
search_result_countNumber of results returned
selected_source_idsSources selected for inspection
inspected_source_idsSources actually inspected
inspected_source_countNumber of inspected sources
source_urlsURLs gathered
source_titlesTitles gathered
source_typesOfficial, expert, commercial, user generated, unknown
source_trust_ratingsTrust ratings
source_freshness_ratingsFreshness ratings
conflicting_sources_detectedYes or no
source_inspection_failuresFailed inspections

Recommended Search History Item

{
"query": "current Google Ads policy health claims 2026",
"reason": "Need current official policy evidence",
"timestamp": "",
"result_count": 10,
"useful_result_count": 3,
"follow_up_needed": true
}

Rule

Important research decisions should not rely only on final answer text.

The loop context must preserve search and source history.


7. Evidence Context

Evidence Context tracks what has been learned and whether it is enough.

Recommended fields:

FieldDescription
evidence_itemsEvidence gathered
evidence_summaryShort summary of current evidence
evidence_sufficiencyWeak, acceptable, strong
evidence_gapsMissing evidence
claim_support_mapClaims mapped to evidence
source_conflictsConflicting evidence notes
assumptions_madeAssumptions used
confidence_basisWhy confidence is high or low
freshness_statusCurrent, acceptable, outdated, unknown
factuality_riskLow, medium, high
answer_readyYes or no

Recommended Evidence Item

{
"evidence_id": "",
"source_id": "",
"claim_supported": "",
"evidence_summary": "",
"freshness": "current",
"trust_rating": "high",
"used_in_final_answer": true,
"limitations": ""
}

Rule

The loop should not choose final answer if evidence is not sufficient for the workflow risk level.


8. Database Context

Database Context tracks internal MWMS records involved in the workflow.

Recommended fields:

FieldDescription
database_providerSupabase, WordPress, Google Sheets, other
records_readInternal records read
records_writtenInternal records created
records_updatedInternal records updated
records_failedFailed record operations
parent_record_idMain parent record
source_record_idsRelated source records
task_event_idsRelated task events
queue_record_idQueue item ID
output_record_idFinal saved output
db_operation_statusSuccessful, partial, failed
db_error_summaryDatabase errors
duplicate_detectedYes or no
permission_statusAllowed, denied, unknown

Rule

The final answer is not complete if required database writes, task updates, or record linkages fail.

Database failures must remain visible in context.


9. Tool And Failure Context

Tool And Failure Context tracks tool use, errors, retries, and blocked actions.

Recommended fields:

FieldDescription
tools_usedList of tools used
tool_call_historyHistory of tool calls
failed_toolsTools that failed
tool_failure_countNumber of tool failures
retry_countNumber of retries
retry_historyRetry records
rate_limit_detectedYes or no
permission_failure_detectedYes or no
timeout_detectedYes or no
blocked_action_detectedYes or no
failure_summaryCurrent failure state
fallback_usedYes or no

Recommended Tool Call Item

{
"tool_name": "scraper",
"tool_type": "source_inspection",
"input_summary": "Inspect official vendor page",
"status": "failed",
"error_summary": "Page blocked extraction",
"retry_count": 1,
"latency_ms": 3000,
"result_used": false
}

Rule

Failures are part of the context, not noise.

A loop that hides failures cannot be trusted.


10. Cost And Performance Context

Cost And Performance Context tracks whether the workflow is still worth continuing.

Recommended fields:

FieldDescription
started_atWorkflow start time
updated_atLast update time
total_latency_msTotal elapsed time
model_latency_msModel latency
tool_latency_msTool latency
database_latency_msDatabase latency
crawler_latency_msCrawler latency
token_usageInput, output, total tokens
model_cost_estimateEstimated model cost
tool_cost_estimateEstimated tool cost
total_cost_estimateEstimated total cost
cost_limit_reachedYes or no
latency_limit_reachedYes or no
performance_warningWarning if slow or expensive

Rule

The loop context must know when cost, time, token, or tool limits are being approached.

The AI Employee should not spend blindly.


11. Review And Decision Context

Review And Decision Context tracks human review, routing, escalation, and decision state.

Recommended fields:

FieldDescription
human_review_requiredYes or no
review_reasonWhy review is required
reviewed_byHuman reviewer
review_statusPending, approved, rejected, needs revision
decision_outcomeProceed, reject, park, route, test, monitor, escalate
routed_to_brainDestination Brain
routed_to_employeeDestination AI Employee
escalation_requiredYes or no
escalation_reasonReason for escalation
risk_notesNotes about business, compliance, finance, or client risk
approval_statusApproved, blocked, pending
next_human_actionWhat the human should do next

Rule

The loop context must not treat decision state as separate from the workflow.

If a decision is made, the context should show why and what happens next.


12. Final Output And Kaizen Context

Final Output And Kaizen Context records the result of the loop and improvement notes.

Recommended fields:

FieldDescription
final_output_createdYes or no
final_output_typeAnswer, report, route, task, escalation, failure, parked record
final_output_locationWhere final output is stored
final_answer_summaryShort summary of output
final_confidenceFinal confidence score
final_limitationsLimitations of output
stop_reasonWhy the loop ended
completion_statusCompleted, partial, failed, parked, escalated
evaluation_scoreScorecard result if available
regression_case_createdYes or no
kaizen_noteImprovement note
improvement_categoryPrompt, tool, source, workflow, evaluation, context
recommended_follow_upNext improvement action

Rule

Every loop must end with a controlled final state.

No silent endings.

No unresolved loop state.


Recommended Full Context Object

The following is a conceptual schema for future implementation.

{
"context_id": "",
"loop_id": "",
"trace_id": "",
"created_at": "",
"updated_at": "",
"environment": "",
"user_id": "",
"user_name": "",
"user_role": "",
"request_origin": "",
"brain_name": "",
"brain_site": "",
"ai_employee_name": "",
"ai_employee_role": "",
"workflow_type": "",
"workflow_name": "",
"task_id": "",
"thread_id": "",
"parent_record_id": "",
"run_id": "",
"workflow_stage": "",
"status": "",
"priority": "",
"urgency": "",
"risk_level": "",
"trigger_type": "",
"original_request": "",
"workflow_goal": "",
"expected_output_type": "",
"success_criteria": [],
"required_evidence_level": "",
"required_freshness_level": "",
"required_confidence_threshold": 0,
"user_constraints": [],
"business_constraints": [],
"completion_definition": "",
"current_step": 0,
"max_steps": 0,
"max_searches": 0,
"max_sources_to_inspect": 0,
"max_database_queries": 0,
"max_retries": 0,
"max_cost": 0,
"max_latency_ms": 0,
"max_tokens": 0,
"allowed_actions": [],
"allowed_tools": [],
"stop_conditions": [],
"escalation_conditions": [],
"fallback_action": "",
"model_policy": "",
"action_history": [],
"previous_action_type": "",
"previous_action_status": "",
"selected_next_action": "",
"selected_action_reason": "",
"duplicate_action_detected": false,
"action_count_by_type": {},
"action_picker_confidence": 0,
"invalid_action_attempted": false,
"action_evaluation_result": "",
"search_history": [],
"search_count": 0,
"search_provider": "",
"search_result_count": 0,
"selected_source_ids": [],
"inspected_source_ids": [],
"inspected_source_count": 0,
"source_urls": [],
"source_titles": [],
"source_types": [],
"source_trust_ratings": [],
"source_freshness_ratings": [],
"conflicting_sources_detected": false,
"source_inspection_failures": [],
"evidence_items": [],
"evidence_summary": "",
"evidence_sufficiency": "",
"evidence_gaps": [],
"claim_support_map": [],
"source_conflicts": [],
"assumptions_made": [],
"confidence_basis": "",
"freshness_status": "",
"factuality_risk": "",
"answer_ready": false,
"database_provider": "",
"records_read": [],
"records_written": [],
"records_updated": [],
"records_failed": [],
"source_record_ids": [],
"task_event_ids": [],
"queue_record_id": "",
"output_record_id": "",
"db_operation_status": "",
"db_error_summary": "",
"duplicate_detected": false,
"permission_status": "",
"tools_used": [],
"tool_call_history": [],
"failed_tools": [],
"tool_failure_count": 0,
"retry_count": 0,
"retry_history": [],
"rate_limit_detected": false,
"permission_failure_detected": false,
"timeout_detected": false,
"blocked_action_detected": false,
"failure_summary": "",
"fallback_used": false,
"started_at": "",
"total_latency_ms": 0,
"model_latency_ms": 0,
"tool_latency_ms": 0,
"database_latency_ms": 0,
"crawler_latency_ms": 0,
"token_usage": {
"input_tokens": 0,
"output_tokens": 0,
"total_tokens": 0
},
"model_cost_estimate": 0,
"tool_cost_estimate": 0,
"total_cost_estimate": 0,
"cost_limit_reached": false,
"latency_limit_reached": false,
"performance_warning": "",
"human_review_required": false,
"review_reason": "",
"reviewed_by": "",
"review_status": "",
"decision_outcome": "",
"routed_to_brain": "",
"routed_to_employee": "",
"escalation_required": false,
"escalation_reason": "",
"risk_notes": [],
"approval_status": "",
"next_human_action": "",
"final_output_created": false,
"final_output_type": "",
"final_output_location": "",
"final_answer_summary": "",
"final_confidence": 0,
"final_limitations": [],
"stop_reason": "",
"completion_status": "",
"evaluation_score": 0,
"regression_case_created": false,
"kaizen_note": "",
"improvement_category": "",
"recommended_follow_up": ""
}

This is not mandatory as exact code.

It is the conceptual schema to guide future build work.


Minimum Required Context

MWMS does not need every field from day one.

Minimum starting context should include:

FieldRequirement
context_idRequired
loop_idRequired where loop exists
trace_idRequired where observability exists
brain_nameRequired
ai_employee_nameRequired where applicable
workflow_typeRequired
task_id or thread_idRequired where applicable
original_requestRequired
workflow_goalRequired
current_stepRequired
max_stepsRequired
allowed_actionsRequired
action_historyRequired
search_historyRequired for research workflows
inspected_source_idsRequired for source workflows
evidence_summaryRequired for research workflows
tools_usedRequired where tools are used
failure_summaryRequired where failures occur
total_cost_estimateRecommended
human_review_requiredRequired for decision workflows
final_output_locationRequired where output is stored
stop_reasonRequired
kaizen_noteRecommended

Context Quality Levels

MWMS should classify context quality by level.

Level 1: Basic Context

Includes:

  • original request
  • Brain
  • workflow type
  • task or thread ID
  • current step
  • max steps
  • final output

Use for:

  • simple internal replies
  • low-risk workflows
  • early prototypes

Level 2: Operational Context

Includes Level 1 plus:

  • AI Employee
  • allowed actions
  • action history
  • tools used
  • search history where relevant
  • status
  • confidence
  • review flag
  • stop reason

Use for:

  • Brain Room
  • Dev Console
  • internal AI workflows
  • newsletter intelligence

Level 3: Governed Context

Includes Level 2 plus:

  • source history
  • evidence items
  • database records
  • cost
  • latency
  • failures
  • escalation state
  • decision outcome
  • review status

Use for:

  • Deep Search
  • affiliate evaluation
  • ads compliance
  • HeadOffice decision support
  • Research Brain workflows

Level 4: Full Production Context

Includes Level 3 plus:

  • full source trust and freshness
  • claim support map
  • action evaluation result
  • regression status
  • detailed cost and token usage
  • tool latency
  • database operation status
  • Kaizen categorisation
  • model and parameter version references

Use for:

  • production AI Employees
  • client-facing agents
  • high-risk workflows
  • autonomous or semi-autonomous systems

Context Update Rules

The context object must be updated after each major action.

Update triggers include:

  • loop starts
  • next action selected
  • tool call completed
  • search completed
  • source inspected
  • database queried
  • evidence added
  • failure detected
  • retry attempted
  • cost updated
  • confidence changed
  • stop condition triggered
  • human review required
  • final output created
  • route created
  • escalation created
  • Kaizen note added

The loop should not keep working from stale context.


Context Preservation Rule

The original request and workflow goal must never be overwritten.

They may be clarified or supplemented, but the original must remain preserved.

This prevents:

  • goal drift
  • wrong answer generation
  • incorrect routing
  • accidental task replacement
  • loss of user intent

Recommended fields:

  • original_request
  • clarified_request
  • workflow_goal
  • current_interpretation

Context Compaction Rule

Long-running loops may need context compaction.

Compaction should preserve:

  • original request
  • workflow goal
  • action history summary
  • evidence summary
  • source IDs
  • important failures
  • current confidence
  • stop conditions
  • next decision state

Compaction must not delete critical evidence, source IDs, or failure history from storage.

The LLM prompt may receive compacted context, but the system record should preserve full trace where possible.


LLM Readable Context Rule

The context stored in the database may not be the best format for the model.

Before sending context to the LLM, MWMS may format it into clear sections:

Workflow Goal:
...

Current Step:
...

Action History:
...

Evidence Collected:
...

Known Gaps:
...

Limits:
...

Decision Needed:
...

The goal is to make context easy for the model to reason over.

Storage format, LLM format, and human dashboard format can be different.


Context Validation Rule

Before the Next Action Picker runs, the context should be checked for minimum required fields.

Validation should check:

  • original request exists
  • workflow goal exists
  • Brain exists
  • workflow type exists
  • allowed actions exist
  • current step exists
  • max steps exists
  • action history exists
  • stop conditions exist

If critical context is missing, the picker should not proceed normally.

It should choose one of:

  • request more information
  • query database
  • escalate
  • stop with missing context reason

Context And Evidence Rule

Evidence should be stored separately from final answers.

The context should know:

  • what evidence exists
  • where it came from
  • whether it is strong
  • whether it is current
  • whether it conflicts
  • whether it supports the final answer

The final answer should not be the only place evidence appears.

This protects MWMS from polished but unsupported outputs.


Context And Stop Conditions Rule

Stop conditions must be visible in context.

The context should know:

  • max steps
  • current step
  • searches used
  • source inspections used
  • cost used
  • time used
  • retries used
  • confidence threshold
  • escalation triggers

The Next Action Picker cannot make safe decisions if stop conditions are hidden.


Context And Human Review Rule

Human review state must be part of context.

The context should show:

  • whether review is required
  • why review is required
  • who reviewed it
  • what decision was made
  • what follow-up is needed

Human review must not live only in a separate comment or dashboard note.


Context And Kaizen Rule

Kaizen learning should be captured inside or linked from context.

The context should show:

  • what failed
  • what should improve
  • whether an eval should be added
  • whether a regression case should be created
  • whether a prompt needs improvement
  • whether a tool needs improvement
  • whether source rules need improvement
  • whether the Employee should be restricted or promoted

This turns loop execution into system learning.


Context Drift Protection

This schema prevents:

  • AI Employees losing the original request
  • loops working from hidden state
  • repeated tool calls with no memory
  • source evidence disappearing
  • database failures being ignored
  • cost and latency being invisible
  • stop conditions being forgotten
  • review status being detached from output
  • final answers being disconnected from evidence
  • Kaizen learning being lost
  • future developers inventing inconsistent context structures

If context is missing or weak, the loop should not be trusted for important decisions.


Relationship To Other MWMS Standards

This schema supports and should align with:

  • MWMS Agent Loop Control Framework
  • MWMS Next Action Picker Standard
  • MWMS AI Observability Metadata Standard
  • MWMS AI Employee Evaluation Scorecard Standard
  • MWMS Deep Search Quality And Observability Framework
  • MWMS AI Agent Operations Core
  • MWMS AI Tool Permission And Access Framework
  • MWMS AI Workflow Pipeline Standard
  • MWMS AI Schema And Decision Ready Output Framework
  • MWMS AI Output Validation Standard
  • MWMS Agentic Reporting Standard
  • MWMS Supabase Event Schema
  • MWMS Brain Room Architecture
  • HeadOffice Operational Intelligence Framework
  • Research Brain Source Evaluation Framework
  • Data Brain Measurement Integrity Framework
  • Experimentation Brain Canon
  • MWMS Kaizen Continuous Improvement Loop
  • MWMS System Change Log

This schema does not replace those pages.

It defines the shared state structure required for controlled AI Employee loops.


Implementation Notes For M And Future Developers

This page is a schema standard, not a demand to implement everything immediately.

Recommended build approach:

  1. Start with minimum context fields.
  2. Add loop ID and trace ID.
  3. Add Brain and AI Employee ownership.
  4. Add action history.
  5. Add allowed actions and stop conditions.
  6. Add search/source history for research workflows.
  7. Add evidence summary and source IDs.
  8. Add failure and retry history.
  9. Add cost and latency fields.
  10. Add review and decision fields.
  11. Add Kaizen fields.
  12. Later, add full production context and dashboard views.

Do not block progress waiting for perfect context.

But do not build autonomous AI Employees that lack context.


Minimum Starting Implementation For MWMS

For early MWMS implementation, start with:

{
"context_id": "",
"loop_id": "",
"trace_id": "",
"brain_name": "",
"ai_employee_name": "",
"workflow_type": "",
"task_id": "",
"thread_id": "",
"original_request": "",
"workflow_goal": "",
"current_step": 0,
"max_steps": 0,
"allowed_actions": [],
"action_history": [],
"search_history": [],
"inspected_source_ids": [],
"evidence_summary": "",
"tools_used": [],
"failure_summary": "",
"human_review_required": false,
"final_output_location": "",
"stop_reason": "",
"kaizen_note": ""
}

This gives MWMS enough structure to support controlled loops without overbuilding.


Future Enhancements

Future enhancements may include:

  • MWMS Agent Stop Condition Standard
  • MWMS Agent Action Registry
  • MWMS Agent Loop Dashboard Specification
  • MWMS Deep Search Source Record Standard
  • MWMS Eval Dataset Registry
  • MWMS Agent Loop Regression Test Library
  • MWMS Prompt Versioning And Parameter Control Standard
  • MWMS AI Employee Autonomy Level Standard
  • MWMS AI Employee Promotion And Restriction Standard

These should only be created when implementation or course material justifies them.


Architectural Intent

The architectural intent of this schema is to make AI Employee loops stateful, controlled, and reviewable.

MWMS is not building disposable chatbot responses.

MWMS is building AI Employees that perform work inside a business operating system.

For that to work, each Employee needs structured context.

The context object is the operational memory of the workflow.

It keeps the AI Employee aligned with the original task, aware of prior actions, aware of evidence, aware of limits, aware of failures, and accountable to HeadOffice.

A strong context schema turns AI action into governed work.


Change Log

v1.0 Initial Draft

Created the MWMS Agent Loop Context Schema based on absorbed insights from Matt Pocock AIhero Build DeepSearch In TypeScript.

Integrated principles from course blocks covering:

  • shared workflow context
  • controlled agent loops
  • next-action picker dependency
  • original request preservation
  • action history
  • search and source history
  • evidence tracking
  • database context
  • tool failure tracking
  • cost and performance state
  • stop condition awareness
  • review and decision state
  • Kaizen learning capture
  • context formatting for LLM reasoning
  • context validation before action selection

Established this schema as the MWMS standard for shared state inside AI Employee agent loops.