Building Agent-Like Systems with ObjectWeaver: From Linear Chains to Composable Intelligence
AI agents promise autonomous reasoning and dynamic tool use, but traditional frameworks like LangChain and LangGraph sacrifice transparency for autonomy. ObjectWeaver takes a different approach: composable, structured intelligence where every decision is an inspectable object, every workflow is explicitly defined, and 100% JSON reliability enables sophisticated multi-step systems without the debugging nightmares of opaque agent loops.
This article explores how ObjectWeaver composes agent-like capabilities—reasoning, tool selection, conditional branching, state management—through guaranteed structured objects instead of unpredictable ReAct loops.
The Agent Architecture Problem
Traditional AI agents follow a simple model:
- Brain: The LLM makes decisions
- Hands: Tools the agent can invoke (search, calculator, APIs, databases)
- Loop: The agent reasons, acts, observes, and repeats until the task completes
This autonomy comes with critical drawbacks:
LangChain: Linear But Opaque
LangChain agents follow the ReAct (Reason + Act) pattern:
The ReAct Loop:
- Reason: LLM thinks about the goal
- Act: LLM selects a tool to use
- Observe: Tool executes and returns results
- Repeat: Loop back to reasoning with new observations
This linear flow works for simple tasks but has fundamental limitations:
- Debugging Opacity: When the agent fails, you read conversation logs hoping to understand what went wrong
- No Intermediate Structure: Tool selections and reasoning are buried in text responses
- Limited Branching: Hard to implement sophisticated conditional logic
- Unpredictable Outputs: Tool calls might succeed or fail, with handling buried in prompts
LangGraph: Complex Control, Still Opaque
LangGraph improves flexibility through stateful graphs:
Key Components:
- State: Central memory object storing all information
- Nodes: Functions or tools (call LLM, search web, format answer)
- Edges: Connections defining flow, including conditional branches
This enables loops, conditional routing, and human-in-the-loop patterns. But core problems remain:
- Still Text-Based Decisions: Nodes return text that needs parsing
- Implicit Contracts: No guaranteed structure between nodes
- Debugging Difficulty: Complex graphs mean more places for opaque failures
- No Field-Level Intelligence: Every node processes with uniform capability
ObjectWeaver's Approach: Composable Structured Intelligence
ObjectWeaver builds agent-like systems through composition of guaranteed structured objects instead of autonomous loops with unpredictable outputs.
Core Principles
1. Every Decision is a Structured Object
Instead of opaque reasoning buried in agent logs, ObjectWeaver structures every decision as a guaranteed JSON object:
View Decision Object Schema
{
"type": "object",
"instruction": "Analyze the user request and determine next action",
"properties": {
"request_type": {
"type": "string",
"instruction": "Classify the type of request: query, task, conversation"
},
"complexity": {
"type": "string",
"instruction": "Assess complexity: simple, moderate, complex"
},
"requires_tools": {
"type": "boolean",
"instruction": "Does this require external tool use?"
},
"suggested_tools": {
"type": "array",
"instruction": "List which tools would be helpful",
"items": {
"type": "object",
"properties": {
"tool": {"type": "string"},
"reason": {"type": "string"}
}
}
},
"reasoning": {
"type": "string",
"instruction": "Explain this assessment"
},
"confidence": {
"type": "number",
"instruction": "Confidence in this analysis (0.0-1.0)"
}
}
}
100% guaranteed structure means this decision object is always valid JSON—no parsing errors, no defensive coding, ready for composition.
2. Explicit State Through Document Accumulation
ObjectWeaver uses a "Document-as-State" model. Unlike LangGraph which maintains a separate state object that nodes read from and write to, ObjectWeaver's state is the JSON document itself.
As fields are generated based on the processingOrder, the document grows. Later fields have access to the exact, structured output of earlier fields.
View Field Dependencies Schema
{
"type": "object",
"instruction": "Execute multi-step research workflow",
"properties": {
"search_query": {
"type": "string",
"instruction": "Formulate the optimal search query"
},
"search_results": {
"type": "object",
"processingOrder": ["search_query"],
"instruction": "Execute search using the query",
"properties": {
"raw_results": {
"type": "string",
"instruction": "Execute search and return raw findings using: {{search_query}}"
},
"analysis": {
"type": "object",
"processingOrder": ["raw_results"],
"instruction": "Analyze the search results",
"properties": {
"key_findings": {
"type": "array",
"instruction": "Extract key findings from raw results",
"items": {
"type": "object",
"properties": {
"finding": {"type": "string"},
"relevance": {"type": "string"}
}
}
},
"confidence_score": {
"type": "number",
"instruction": "Rate confidence in findings (0.0-1.0) based on source quality"
}
}
}
}
},
"synthesis": {
"type": "string",
"processingOrder": ["search_results"],
"instruction": "Synthesize findings into actionable insights: {{search_results.analysis.key_findings}}"
}
}
}
This creates a directed acyclic graph (DAG) of dependencies, similar to LangGraph's edges but with:
- Guaranteed structure at every step: Each field returns valid JSON
- Explicit data contracts: Field dependencies are declared, not inferred
- Parallel execution: Independent fields generate concurrently
- Inspectable state: The "state" is just the JSON document, which is always readable
A Note on Tool Execution: ObjectWeaver orchestrates the decision to use a tool and generates the arguments for it (as structured JSON). The actual execution of the tool (e.g., calling the Google Search API) is handled by your application code or an external executor, which then feeds the result back into the context. This separation of concerns keeps the orchestration logic pure and the execution logic flexible.
3. Conditional Logic Through Decision Points
ObjectWeaver embeds conditional branching directly in schemas through decision points:
View Decision Point Schema
{
"type": "object",
"instruction": "Generate customer response with quality adaptation",
"properties": {
"initial_response": {
"type": "string",
"instruction": "Generate initial response to customer inquiry"
},
"response_evaluation": {
"type": "object",
"processingOrder": ["initial_response"],
"instruction": "Evaluate and improve response as needed",
"properties": {
"quality_check": {
"type": "object",
"properties": {
"clarity_score": {"type": "number"},
"completeness_score": {"type": "number"},
"professionalism_score": {"type": "number"},
"overall_score": {"type": "number"},
"passes": {"type": "boolean"}
}
},
"improved_response": {
"type": "string",
"processingOrder": ["quality_check"],
"instruction": "Rewrite the response addressing clarity and completeness issues",
"scoringCriteria": {
"dimensions": {
"clarity": {
"description": "Rate clarity from 0-10",
"type": "number"
},
"completeness": {
"description": "Rate completeness from 0-10",
"type": "number"
}
}
},
"decisionPoint": {
"name": "QualityRouter",
"branches": [
{
"name": "NeedsImprovement",
"conditions": [
{
"field": "clarity",
"operator": "lt",
"number_value": 7
}
],
"then": {
"type": "string",
"instruction": "Further improve the response"
}
}
]
}
}
}
},
"final_response": {
"type": "string",
"processingOrder": ["response_evaluation"],
"instruction": "Select the best response version based on quality scores"
}
}
}
Decision points enable:
- Automatic quality-based branching: Low scores trigger refinement branches
- Conditional field generation: Fields with decision points only execute their branches when conditions match
- Structured evaluation: Scoring criteria integrated with each field
- Guaranteed structure: All conditional outputs are valid JSON
This replaces complex conditional edges in LangGraph with declarative logic that's easier to understand, modify, and debug. Note that decision points are attached to individual fields that have scoringCriteria, not to parent objects.
4. Model Specialization Per Field
Unlike agent frameworks where one model handles everything, ObjectWeaver enables per-field model routing:
View Multi-Model Schema
{
"type": "object",
"instruction": "Multi-model research and analysis workflow",
"properties": {
"classification": {
"type": "string",
"model": "gpt-3.5-turbo",
"instruction": "Classify the research topic area"
},
"planning": {
"type": "object",
"model": "gpt-3.5-turbo",
"processingOrder": ["classification"],
"instruction": "Plan the research approach",
"properties": {
"search_strategy": {
"type": "object",
"properties": {
"keywords": {
"type": "array",
"items": {
"type": "object",
"properties": {
"keyword": {"type": "string"}
}
}
},
"approach": {"type": "string"}
}
},
"deep_analysis": {
"type": "string",
"model": "gpt-4",
"processingOrder": ["search_strategy"],
"instruction": "Perform deep analysis requiring complex reasoning"
},
"technical_details": {
"type": "object",
"model": "gpt-4",
"processingOrder": ["deep_analysis"],
"properties": {
"methodology": {"type": "string"},
"implications": {"type": "string"},
"recommendations": {
"type": "array",
"items": {
"type": "object",
"properties": {
"recommendation": {"type": "string"}
}
}
}
}
}
}
},
"summary": {
"type": "string",
"model": "gpt-3.5-turbo",
"processingOrder": ["planning"],
"instruction": "Summarize findings in accessible language"
}
}
}
Cost optimization through intelligence:
- Simple classification and summarization → gpt-3.5-turbo ($0.50/1M tokens)
- Complex reasoning and analysis → gpt-4 ($30/1M tokens)
- 10-20× cost reduction compared to routing everything through one capable model
Traditional agents can't do this—they commit to one model for the entire workflow.
Building Agent-Like Systems: Practical Patterns
Pattern 1: The Research Agent
- Traditional Agent (LangChain)
- ObjectWeaver Approach
Linear ReAct Loop with Unpredictable Outputs:
Problems:
- Unpredictable output format at each step
- Hard to debug when something fails
- No cost optimization
- Sequential processing only
Structured Workflow with Guaranteed Outputs:
Advantages:
- 100% guaranteed JSON at every step
- Clear inspection points for debugging
- Per-field model routing for cost optimization
- Parallel execution where possible
- Automatic quality loops
View Complete ObjectWeaver Research Agent Schema
{
"type": "object",
"instruction": "Execute comprehensive research workflow",
"properties": {
"query_understanding": {
"type": "object",
"model": "gpt-3.5-turbo",
"properties": {
"main_question": {"type": "string"},
"sub_questions": {
"type": "array",
"items": {
"type": "object",
"properties": {
"question": {"type": "string"}
}
}
},
"required_depth": {"type": "string"}
}
},
"research_execution": {
"type": "object",
"processingOrder": ["query_understanding"],
"instruction": "Execute search and synthesize findings",
"properties": {
"search_execution": {
"type": "object",
"model": "gpt-3.5-turbo",
"properties": {
"primary_search": {"type": "string"},
"secondary_searches": {
"type": "array",
"items": {
"type": "object",
"properties": {
"search_query": {"type": "string"},
"rationale": {"type": "string"}
}
}
},
"sources_found": {"type": "number"}
}
},
"information_synthesis": {
"type": "object",
"model": "gpt-4",
"processingOrder": ["search_execution"],
"properties": {
"main_findings": {
"type": "array",
"items": {
"type": "object",
"properties": {
"finding": {"type": "string"},
"significance": {"type": "string"}
}
}
},
"supporting_evidence": {
"type": "array",
"items": {
"type": "object",
"properties": {
"evidence": {"type": "string"},
"source": {"type": "string"}
}
}
},
"confidence_level": {"type": "number"}
}
}
}
},
"quality_validation": {
"type": "object",
"processingOrder": ["research_execution"],
"instruction": "Assess quality and perform additional research if needed",
"properties": {
"quality_assessment": {
"type": "object",
"properties": {
"completeness_score": {"type": "number"},
"accuracy_score": {"type": "number"},
"needs_more_research": {"type": "boolean"}
}
},
"additional_research": {
"type": "object",
"processingOrder": ["quality_assessment"],
"scoringCriteria": {
"dimensions": {
"completeness": {
"description": "Rate completeness from 0-10",
"type": "number"
},
"accuracy": {
"description": "Rate accuracy from 0-10",
"type": "number"
}
}
},
"decisionPoint": {
"name": "ResearchQualityRouter",
"branches": [
{
"name": "NeedsMoreResearch",
"conditions": [
{
"field": "completeness",
"operator": "lt",
"number_value": 8
},
{
"field": "accuracy",
"operator": "lt",
"number_value": 8
}
],
"then": {
"type": "object",
"properties": {
"gaps_identified": {
"type": "array",
"items": {
"type": "object",
"properties": {
"gap": {"type": "string"},
"priority": {"type": "string"}
}
}
},
"supplemental_findings": {"type": "string"}
}
}
}
]
}
},
"final_report": {
"type": "object",
"model": "gpt-4",
"properties": {
"executive_summary": {"type": "string"},
"detailed_findings": {"type": "string"},
"recommendations": {
"type": "array",
"items": {
"type": "object",
"properties": {
"recommendation": {"type": "string"},
"rationale": {"type": "string"}
}
}
},
"limitations": {"type": "string"}
}
}
}
}
Pattern 2: The Customer Support Agent
- LangGraph (Stateful)
- ObjectWeaver Approach
Complex State Management:
Problems:
- Manual state object management
- Text-based decisions need parsing
- Complex graph = more failure points
- No per-node model optimization
Structured Dependency Flow:
Advantages:
- No manual state management
- 100% guaranteed structure
- Cost-optimized per field
- Automatic quality improvement
View Complete Customer Support Agent Schema
{
"type": "object",
"instruction": "Handle customer support inquiry end-to-end",
"properties": {
"intake": {
"type": "object",
"model": "gpt-3.5-turbo",
"properties": {
"issue_category": {"type": "string"},
"urgency": {"type": "string"},
"sentiment": {"type": "string"},
"customer_history_relevant": {"type": "boolean"}
}
},
"routing_decision": {
"type": "object",
"model": "gpt-3.5-turbo",
"processingOrder": ["intake"],
"properties": {
"escalate_to_human": {"type": "boolean"},
"requires_specialist": {"type": "boolean"},
"specialist_type": {"type": "string"},
"priority_level": {"type": "string"},
"reasoning": {"type": "string"}
}
},
"response_workflow": {
"type": "object",
"processingOrder": ["intake", "routing_decision"],
"instruction": "Generate and validate customer response",
"properties": {
"response_generation": {
"type": "object",
"model": "gpt-4",
"properties": {
"response_message": {"type": "string"},
"tone_used": {"type": "string"},
"offers_made": {
"type": "array",
"items": {
"type": "object",
"properties": {
"offer": {"type": "string"},
"value": {"type": "string"}
}
}
},
"next_steps": {"type": "string"}
}
},
"quality_validation": {
"type": "object",
"model": "gpt-3.5-turbo",
"processingOrder": ["response_generation"],
"properties": {
"empathy_score": {"type": "number"},
"clarity_score": {"type": "number"},
"completeness_score": {"type": "number"},
"approved": {"type": "boolean"}
}
},
"improved_response": {
"type": "object",
"model": "gpt-4",
"processingOrder": ["response_generation", "quality_validation"],
"scoringCriteria": {
"dimensions": {
"empathy": {
"description": "Rate empathy from 0-10",
"type": "number"
},
"clarity": {
"description": "Rate clarity from 0-10",
"type": "number"
},
"completeness": {
"description": "Rate completeness from 0-10",
"type": "number"
}
}
},
"decisionPoint": {
"name": "ResponseQualityRouter",
"branches": [
{
"name": "NeedsImprovement",
"conditions": [
{
"field": "empathy",
"operator": "lt",
"number_value": 8
},
{
"field": "clarity",
"operator": "lt",
"number_value": 8
},
{
"field": "completeness",
"operator": "lt",
"number_value": 8
}
],
"then": {
"type": "object",
"properties": {
"revised_message": {"type": "string"},
"improvements_made": {
"type": "array",
"items": {
"type": "object",
"properties": {
"improvement": {"type": "string"}
}
}
}
}
}
}
]
}
}
},
"follow_up_plan": {
"type": "object",
"model": "gpt-3.5-turbo",
"processingOrder": ["routing_decision", "response_workflow"],
"properties": {
"schedule_follow_up": {"type": "boolean"},
"follow_up_date": {"type": "string"},
"follow_up_type": {"type": "string"},
"notes_for_team": {"type": "string"}
}
}
}
}
Pattern 3: The Multi-Step Reasoning Agent
Traditional Agent Challenge:
Complex reasoning tasks require multiple steps, but traditional agents struggle with unpredictable outputs at each stage.
Each step returns unpredictable text format, making composition fragile
ObjectWeaver Solution:
Every step returns guaranteed valid JSON, enabling reliable composition
View Complete Multi-Step Reasoning Agent Schema
{
"type": "object",
"instruction": "Solve complex problem through structured decomposition",
"properties": {
"problem_analysis": {
"type": "object",
"model": "gpt-4",
"properties": {
"problem_statement": {"type": "string"},
"constraints": {
"type": "array",
"items": {
"type": "object",
"properties": {
"constraint": {"type": "string"}
}
}
},
"success_criteria": {
"type": "array",
"items": {
"type": "object",
"properties": {
"criterion": {"type": "string"}
}
}
},
"sub_problems": {
"type": "array",
"items": {
"type": "object",
"properties": {
"description": {"type": "string"},
"complexity": {"type": "string"},
"dependencies": {
"type": "array",
"items": {
"type": "object",
"properties": {
"dependency": {"type": "string"}
}
}
}
}
}
}
}
},
"solution_development": {
"type": "object",
"processingOrder": ["problem_analysis"],
"instruction": "Develop and integrate solution",
"properties": {
"solution_strategy": {
"type": "object",
"model": "gpt-4",
"properties": {
"approach": {"type": "string"},
"execution_order": {
"type": "array",
"items": {
"type": "object",
"properties": {
"step": {"type": "string"},
"order": {"type": "number"}
}
}
},
"risk_factors": {
"type": "array",
"items": {
"type": "object",
"properties": {
"risk": {"type": "string"},
"mitigation": {"type": "string"}
}
}
},
"estimated_complexity": {"type": "string"}
}
},
"sub_solutions": {
"type": "array",
"model": "gpt-4",
"processingOrder": ["solution_strategy"],
"items": {
"type": "object",
"properties": {
"problem_id": {"type": "string"},
"solution": {"type": "string"},
"reasoning": {"type": "string"},
"confidence": {"type": "number"}
}
}
},
"solution_integration": {
"type": "object",
"model": "gpt-4",
"processingOrder": ["sub_solutions"],
"properties": {
"integrated_solution": {"type": "string"},
"how_parts_connect": {"type": "string"},
"potential_issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"issue": {"type": "string"},
"severity": {"type": "string"}
}
}
}
}
}
}
},
"validation_workflow": {
"type": "object",
"processingOrder": ["problem_analysis", "solution_development"],
"instruction": "Validate and revise solution",
"properties": {
"validation": {
"type": "object",
"model": "gpt-4",
"properties": {
"meets_constraints_score": {"type": "number"},
"meets_success_criteria_score": {"type": "number"},
"logical_consistency_score": {"type": "number"},
"is_valid": {"type": "boolean"},
"validation_notes": {"type": "string"}
}
},
"revised_solution": {
"type": "object",
"model": "gpt-4",
"processingOrder": ["validation"],
"scoringCriteria": {
"dimensions": {
"meets_constraints": {
"description": "Rate how well solution meets constraints from 0-10",
"type": "number"
},
"meets_success_criteria": {
"description": "Rate how well solution meets success criteria from 0-10",
"type": "number"
}
}
},
"decisionPoint": {
"name": "ValidationRouter",
"branches": [
{
"name": "NeedsRevision",
"conditions": [
{
"field": "meets_constraints",
"operator": "lt",
"number_value": 9
},
{
"field": "meets_success_criteria",
"operator": "lt",
"number_value": 9
}
],
"then": {
"type": "object",
"properties": {
"issues_found": {
"type": "array",
"items": {
"type": "object",
"properties": {
"issue": {"type": "string"},
"impact": {"type": "string"}
}
}
},
"corrected_solution": {"type": "string"}
}
}
}
]
}
}
}
},
"final_answer": {
"type": "object",
"model": "gpt-4",
"processingOrder": ["solution_development", "validation_workflow"],
"properties": {
"solution": {"type": "string"},
"explanation": {"type": "string"},
"confidence_level": {"type": "number"},
"alternative_approaches": {
"type": "array",
"items": {
"type": "object",
"properties": {
"approach": {"type": "string"},
"pros_cons": {"type": "string"}
}
}
}
}
}
}
}
The ObjectWeaver Advantage Over Traditional Agents
| Aspect | Traditional Agents (LangChain/LangGraph) | ObjectWeaver |
|---|---|---|
| Output Reliability | ~70-95% (depends on prompting) | 100% guaranteed JSON |
| Decision Visibility | Buried in text logs | Structured objects |
| Debugging | Read conversation history, guess failure point | Inspect exact decision object that failed |
| Conditional Logic | Complex graph edges or prompt engineering | Declarative decision points in schema |
| State Management | Manual state object passing | Explicit field dependencies |
| Model Selection | One model for entire workflow | Per-field model routing |
| Cost Optimization | All tasks use capable model | Simple tasks use cheap models |
| Composition | Hope output format is parseable | Guaranteed structure enables reliable composition |
| Modification | Adjust prompts, hope nothing breaks | Update schema, relationships stay intact |
| Testing | Stochastic outputs, hard to test | Clear input/output contracts |
| Parallelization | Sequential token generation | Independent fields generate concurrently |
When to Use ObjectWeaver vs Traditional Agents
Choose Traditional Agents When:
- You need fully autonomous operation without structured checkpoints
- The task is exploratory with unknown steps
- You're fine with ~70-95% reliability and manual error handling
- Output structure doesn't matter
- You have simple, uniform workflows
Choose ObjectWeaver When:
- You need guaranteed structured outputs for composition
- Decisions must be transparent and auditable
- You want cost optimization through per-field model routing
- You need conditional logic based on quality or criteria
- You're building production systems requiring reliability
- You need debuggable workflows with clear failure points
- You want reusable components across multiple workflows
- Your workflow has field dependencies that should be explicit
Composing Agent-Like Intelligence: The ObjectWeaver Way
ObjectWeaver doesn't build "agents" in the traditional sense. It builds composable intelligent systems through guaranteed structured objects.
The Architecture Difference
- Traditional Agent Architecture
- ObjectWeaver Composable Architecture
Characteristics:
- Opaque reasoning
- Unpredictable output formats
- Hard to debug failures
- One model for everything
- Sequential processing
Characteristics:
- Transparent structured decisions
- 100% guaranteed valid JSON
- Clear debugging points
- Per-field model optimization
- Parallel + sequential execution
Seven Principles of Composable Intelligence
- Guaranteed Structure: 100% JSON reliability enables confident composition
- Explicit Dependencies:
processingOrdercreates clear data flow graphs - Embedded Conditional Logic: Decision points replace complex branching
- Field-Level Model Routing: Right model for each task, optimized cost
- Transparent Decisions: Every choice is an inspectable structured object
- Parallel Execution: Independent fields generate concurrently
- Compositional Validation: Each field validates independently
This approach delivers agent-like capabilities—reasoning, tool selection, conditional branching, multi-step workflows—with the transparency, reliability, and debuggability that production systems demand.
Traditional agents optimize for autonomy. ObjectWeaver optimizes for reliable, composable intelligence.
Build transparent, reliable agent-like systems with guaranteed structured outputs. Explore our documentation to get started with ObjectWeaver's compositional approach.
