Context Engineering Meets Neurosymbolic AI: How We Made Websites Conversational
Every AI engineer has faced this challenge: How do you let users have natural conversations about a website while ensuring the AI takes precise, reliable actions? The answer lies at the intersection of context engineering and neurosymbolic AI design.
At Kaynix AI, we’ve pioneered an approach that bridges free-form conversation with deterministic website automation. Here’s how we combined context engineering principles with neurosymbolic architecture to create truly conversational web experiences.
The Problem: Bridging Language and Action
Traditional approaches to web automation face a fundamental tension:
- Pure neural approaches (LLMs alone): Great at understanding intent, terrible at reliable execution
- Pure symbolic approaches (traditional automation): Perfectly reliable, but rigid and unnatural
What users want is both: Natural conversation that leads to precise action.
Our Solution: A Neurosymbolic Architecture
We designed a system that leverages the strengths of both neural and symbolic approaches:
The Neural Side: Natural Understanding
- LLMs process user intent in natural language
- Generate contextually appropriate responses
- Understand nuanced requests like “find me something similar but cheaper”
The Symbolic Side: Precise Execution
- DOM structure provides explicit website representation
- Selectors and action maps ensure deterministic operations
- Generated code acts as symbolic programs with guaranteed outcomes
The Bridge: Context Engineering
This is where the magic happens. We engineer the context to seamlessly connect neural understanding with symbolic execution.
Context Engineering: The Secret Sauce
1. Structured Offline Exploration
Instead of throwing raw HTML at an LLM and hoping for the best, we use Playwright MCP offline to create structured context:
// Traditional approach: Raw HTML chaos
const html = await page.content(); // 50KB of nested divs
llm.process(html); // Good luck finding that button!
// Our approach: Structured context mapping
const context = await playwrightMCP.explore({
captureSelectors: true,
mapInteractions: true,
identifyPatterns: true
});
// Result: Clean, symbolic representation of actionable elements
This exploration phase creates a symbolic map that the LLM can reliably reference later.
2. File-Based Context Passing
We modified the MCP protocol to overcome token limitations:
// Problem: Token explosion
return {
accessibilityTree: massiveTreeStructure // 10,000+ tokens!
};
// Solution: File-based context
fs.writeFileSync('/tmp/context.json', massiveTreeStructure);
return {
contextPath: '/tmp/context.json' // <100 tokens
};
This innovation allows us to pass rich, persistent context without token constraints, enabling:
- Complete page structure retention
- Incremental updates and caching
- State persistence across interactions
3. Orchestrated Online/Offline Separation
We deliberately separate discovery from execution:
Offline (Heavy Lifting):
- Explore website structure with AI assistance
- Generate reliable automation patterns
- Create high-level APIs from low-level DOM
Online (Lightweight Execution):
- Run pure JavaScript in the browser
- Execute pre-validated patterns
- Maintain conversation context
This separation keeps the live interaction fast while maintaining rich context.
4. Conversation Grounding
We ground every conversation in the actual webpage context:
// User: "What's in my cart?"
// System: Checks actual cart state via symbolic reference
const cartItems = await page.$$eval('.cart-item', items =>
items.map(i => ({
name: i.querySelector('.title').textContent,
price: i.querySelector('.price').textContent
}))
);
// LLM: Uses symbolic cart data for natural response
"You have 2 items in your cart: Nike Pegasus ($127) and running socks ($15)"
The conversation is natural, but grounded in symbolic truth.
Neurosymbolic Benefits in Practice
Eliminating Hallucination
Traditional LLM approaches might “imagine” buttons or invent product details. Our neurosymbolic approach:
// Neural: Understands user wants to add item to cart
userIntent = "add the blue one to my cart"
// Symbolic: Verifies the exact element exists
const blueVariant = await page.$('[data-color="blue"]');
if (!blueVariant) {
return "I don't see a blue option for this product";
}
// Hybrid: Natural response with verified action
await blueVariant.click();
return "I've added the blue variant to your cart";
Handling Complex Interactions
Consider a multi-step checkout process:
// Neural understanding of goal
goal = "complete checkout with express shipping"
// Symbolic execution plan
const checkoutSteps = [
{ action: 'click', selector: '.checkout-btn', verify: '.checkout-form' },
{ action: 'fill', selector: '#email', value: userData.email },
{ action: 'select', selector: '#shipping', value: 'express' },
{ action: 'click', selector: '.place-order', verify: '.confirmation' }
];
// Neurosymbolic execution
for (const step of checkoutSteps) {
// Symbolic: Execute deterministic action
await executeStep(step);
// Neural: Generate contextual updates
await llm.generateStatusUpdate(step, pageContext);
}
Real-World Applications
E-commerce Shopping Assistant
User: "I need running shoes for flat feet under $150"
// Context engineering: Product filters as symbolic constraints
const filters = {
category: 'running-shoes',
features: ['motion-control', 'stability'],
maxPrice: 150
};
// Neurosymbolic execution
const products = await applyFilters(filters); // Symbolic
const recommendation = await llm.recommend(products, userNeeds); // Neural
Response: "I found 3 great options for flat feet support. The Brooks
Adrenaline GTS at $130 has the best motion control rating..."
Form Automation with Understanding
User: "Help me fill out this return form for my defective headphones"
// Neural: Extract relevant information from conversation
const returnReason = await llm.extractReturnContext(conversation);
// Symbolic: Map to exact form fields
const formMapping = {
'#return-reason': returnReason.category,
'#description': returnReason.details,
'#order-number': userData.lastOrder
};
// Hybrid: Fill form with verification
for (const [selector, value] of Object.entries(formMapping)) {
const field = await page.$(selector);
if (field) {
await field.fill(value);
// Neural: Confirm with user naturally
await llm.confirmFieldFill(selector, value);
}
}
The Architecture That Makes It Possible
Development Phase: Context Discovery
Offline Exploration (Playwright MCP)
↓
DOM Structure + Interaction Patterns
↓
Symbolic API Generation
↓
Context Map (File-Based Storage)
Runtime Phase: Neurosymbolic Execution
User Input (Natural Language)
↓
LLM Intent Analysis ← Context Map
↓
Symbolic Action Selection
↓
Deterministic Execution
↓
Natural Response Generation
Key Innovations
1. Modified MCP Protocol
Our file-based enhancement enables unlimited context without token explosion, making complex page understanding economically viable.
2. Offline/Online Orchestration
By separating exploration from execution, we achieve both thorough understanding and fast runtime performance.
3. Symbolic Grounding
Every LLM response is grounded in verifiable page state, eliminating hallucination while maintaining conversational flow.
4. High-Level API Generation
Instead of exposing raw selectors, we generate semantic APIs that survive UI changes:
// Not this:
await page.click('[data-test-id="atc-btn-2024"]');
// But this:
await shopifyStore.addToCart(productId);
Performance Impact
Reliability Metrics
- Action success rate: 99.5% (vs 75% for pure LLM approaches)
- Hallucination rate: <0.1% (vs 15-20% for ungrounded systems)
- UI change resilience: 85% survival rate across updates
Efficiency Gains
- Token usage: 100x reduction through file-based context
- Response time: <500ms for most actions (pre-validated patterns)
- Development time: 10x faster than manual automation scripting
Why This Matters
For Developers
- Build reliable automation without sacrificing natural interaction
- Reduce debugging time with deterministic symbolic execution
- Scale context without token cost explosion
For End Users
- Natural conversation that actually works
- No more “I can’t do that” responses for basic actions
- Confidence that the AI sees what they see
For Businesses
- Deploy conversational interfaces on any website
- Reduce customer support burden with reliable automation
- Enable new interaction paradigms previously impossible
The Future: Beyond Current Limitations
We’re extending this approach to enable:
Cross-Site Context
Maintaining conversation context across multiple websites, enabling true web-wide assistance.
Learned Symbolic Patterns
Using neural networks to discover new symbolic patterns, continuously improving automation coverage.
Distributed Context Engineering
Crowdsourcing context maps for popular websites, creating a shared knowledge base of symbolic web structures.
Conclusion: The Best of Both Worlds
Context engineering and neurosymbolic design aren’t just buzzwords—they’re the key to making AI web automation actually work. By carefully engineering how context flows between neural and symbolic components, we’ve created a system that:
- Understands like a human (neural)
- Acts like a machine (symbolic)
- Converses naturally (hybrid)
The result? Websites become conversational partners, not just static pages. And that changes everything.
Want to make your website conversational with neurosymbolic AI? Check out our Playwright MCP fork or contact us to learn more about our platform.