Skip to main content

UOM Orchestrator: State Representation, Message Isolation & Runtime Context

State management is the backbone of the Universal Object Mapping (UOM) Orchestrator. By utilizing LangGraph’s stateful modeling and structured dataclasses, the service maintains thread-scoped memory, captures intermediate execution artifacts, and applies runtime configurations dynamically.

1. LangGraph State Structure

The state representation of the orchestrator is split across three distinct dataclasses located in react_agent/state.py:
  • InputState: Defines the narrower external boundary representing the data supplied by the client during a request.
  • OutputState: Defines the final schemas, queries, validation logs, and explanations returned to the client upon completion.
  • State: Inherits from both InputState and OutputState, and incorporates internal tracking variables, results caches, and retry loops.

1.1 State Class Attribute Matrix


2. Message Isolation Boundary

One of the most important design decisions in the orchestrator is the separation of messages and translation_messages.

2.1 The Problem: Context Window Pollution

In standard LangGraph implementations, all conversational interactions (chat bubbles, tool invocation logs, and execution errors) are appended to a single, monolithic message list. During ORM translation, the compiler validators inside Daytona frequently return very large outputs (such as Maven build logs containing dependency traces, C# MSBuild compile warning sequences, or hundreds of lines of stack traces). If these logs are appended directly to the user’s primary chat thread:
  1. Model Distraction: The LLM starts referencing past compilation logs instead of focusing on the latest instructions or user edits.
  2. High Latency and API Cost: The prompt size increases exponentially on every turn. A single chat session can easily hit 150,000 tokens, resulting in massive billing costs and slow inference.
  3. Loss of History: Crucial user requirements or design decisions discussed at the beginning of the conversation get squeezed out due to context window truncation.

2.2 The Solution: Isolated Sub-Graph Messaging

The orchestrator maintains an isolated thread for compile-and-retry loops inside state.translation_messages:
  1. Clean Main Thread: When the user requests a translation, the inputs are injected into the isolated translation_messages queue.
  2. Iterative Refinement: All compilation errors, DeepDiff outputs, and model corrections are logged to translation_messages. The core conversational thread remains completely untouched.
  3. Garbage Collection of Noise: Once the translation is completed (either successfully accepted or sent to the human-in-the-loop node), only the final, functional schema/query code and a concise evaluation summary are written back to messages. The dirty, multi-megabyte compilation trails are discarded from the primary chat history.

3. Configuration Context (react_agent/context.py)

Deployment-specific parameters, credentials, connection ports, and timeouts are encapsulated in the Context class. Built as a Pydantic-dataclass, it provides strong typing, schema descriptions, and automatic binding to system environments.

3.1 Eager Environment Binding via Reflection

When a LangGraph graph compiles and executes, it initializes its configurations. If a configuration class is instantiated with blank properties, it can cause immediate execution failures. To solve this, Context overrides __post_init__ using Python’s reflection capabilities:
This guarantees that:
  • Any custom runtime parameters specified in RunnableConfig["configurable"] take immediate precedence.
  • If no values are passed in the execution configuration, the class falls back to environment variables.
  • Standard default constants are applied if neither is present, keeping the server robust.

3.2 Key Configurable Parameters

The following parameters are tracked by Context to govern external tool connections: