Examples

These are conceptual integration examples. They illustrate how ANCHOR signals might be used within existing multi-agent frameworks. None of these examples imply that ANCHOR improves success rates or guarantees outcomes.

All code is pseudo-code and reference only. APIs shown are illustrative, not finalized.


LangGraph Integration (Conceptual)

This example shows how an ANCHOR signal could be read within a LangGraph state graph to influence agent selection. The signal is treated as a weak prior — it biases selection, but the graph's routing logic remains in control.

# LangGraph conceptual integration — not production code
from langgraph.graph import StateGraph
from typing import TypedDict, Optional
import json
 
class AgentState(TypedDict):
    task: str
    selected_agent: Optional[str]
    anchor_signals: dict  # agent_id -> signal dict
 
def collect_anchor_signals(state: AgentState) -> AgentState:
    """
    Collect ANCHOR signals from available agent instances.
    Signals are advisory. Absence of a signal is not an error.
    """
    agents = ["agent-alpha", "agent-beta", "agent-gamma"]
    signals = {}
 
    for agent_id in agents:
        # In practice, this calls your agent's signal endpoint
        sig = fetch_anchor_signal(agent_id)  # returns dict or None
        if sig and sig.get("anchor_version") == "0":
            signals[agent_id] = sig
 
    return {**state, "anchor_signals": signals}
 
def select_agent(state: AgentState) -> AgentState:
    """
    Select an agent using ANCHOR signals as a weak prior.
    The signal informs the decision — it does not make it.
    """
    task = state["task"]
    signals = state["anchor_signals"]
 
    # Base selection logic (your existing criteria)
    candidates = score_agents_by_capability(task)
 
    # Weak prior: mild preference for agents with relevant continuity
    for agent_id, sig in signals.items():
        continuity = sig.get("continuity", {})
        if continuity.get("has_context"):
            session_id = continuity.get("session_id", "")
            if is_session_relevant(session_id, task):
                # Small weight — does not override capability scoring
                candidates[agent_id] = candidates.get(agent_id, 0) + 0.1
 
    # Final selection still depends on full scoring logic,
    # not continuity alone.
    selected = max(candidates, key=candidates.get)
    return {**state, "selected_agent": selected}
 
# Build graph
builder = StateGraph(AgentState)
builder.add_node("collect_signals", collect_anchor_signals)
builder.add_node("select_agent", select_agent)
builder.add_edge("collect_signals", "select_agent")
builder.set_entry_point("collect_signals")
 
graph = builder.compile()

CrewAI Integration (Conceptual)

This example shows how ANCHOR signals might inform crew composition in CrewAI. The signal is consulted before assigning a specialist agent to a task; the crew's task logic is not modified.

# CrewAI conceptual integration — not production code
from crewai import Agent, Task, Crew
 
def build_crew_with_anchor(task_description: str, available_agents: list):
    """
    Build a crew, using ANCHOR signals to prefer agents with
    relevant prior context. Signal is advisory; crew logic decides.
    """
    # Collect signals
    signals = {a.id: fetch_anchor_signal(a.id) for a in available_agents}
 
    # Separate agents by continuity signal
    with_context = []
    without_context = []
 
    for agent in available_agents:
        sig = signals.get(agent.id)
        has_context = (
            sig is not None
            and sig.get("anchor_version") == "0"
            and sig.get("continuity", {}).get("has_context", False)
        )
        if has_context:
            with_context.append(agent)
        else:
            without_context.append(agent)
 
    # NOTE:
    # This is a simplified illustration.
    # In practice, continuity should only bias selection
    # when other criteria are approximately equal.
    preferred = with_context if with_context else without_context
    selected_agent = preferred[0]  # further selection logic can apply here
 
    task = Task(
        description=task_description,
        agent=selected_agent,
    )
 
    crew = Crew(
        agents=[selected_agent],
        tasks=[task],
    )
 
    return crew

Planner Prompt Snippet (Weak Prior)

For LLM-based planners, inject ANCHOR signal data as advisory context. Frame it explicitly as a weak prior — uncertain, unverified, and one factor among many.

def build_planner_prompt(task, agents, signals):
    """
    Inject ANCHOR signals into a planner prompt as advisory context.
    The framing explicitly communicates uncertainty.
    """
    lines = []
    for agent in agents:
        sig = signals.get(agent.id)
        if sig:
            presence = sig.get("presence", {}).get("status", "unknown")
            continuity = sig.get("continuity", {})
            has_ctx = continuity.get("has_context", False)
            depth = continuity.get("context_depth", 0)
 
            note = f"presence={presence}"
            if has_ctx:
                note += f", has prior context (~{depth} interactions)"
        else:
            note = "no signal available"
 
        lines.append(f"  - {agent.id}: {note}")
 
    agent_info = "\n".join(lines)
 
    return f"""You are a task planner allocating work across agent instances.
 
Task: {task.description}
 
Available agents (ANCHOR signals — advisory, unverified):
{agent_info}
 
The ANCHOR signals above are self-reported and non-deterministic.
They indicate presence and prior context, not capability or reliability.
Use them as a weak prior alongside your other criteria.
 
Assign the task to the most appropriate agent. Explain your reasoning.
"""

Pseudo SDK Usage

The following shows a conceptual SDK surface for an agent that emits ANCHOR signals. This is not a published SDK. The API is illustrative only.

This section illustrates a possible API shape only. It does not imply the existence of a reference implementation or official SDK.

# Conceptual ANCHOR SDK usage — not a published library
import anchor
 
# Initialize the ANCHOR signal for this agent instance
anchor.init(
    agent_id="my-agent-001",
    # optional: associate with an ongoing session
    session_id="debugging-auth-refactor",
)
 
# Emit a presence heartbeat (call periodically to maintain presence)
anchor.heartbeat()
 
# Update continuity state as the session progresses
anchor.set_continuity(
    has_context=True,
    context_depth=5,
)
 
# Read back current signal state (for inspection/logging)
current_signal = anchor.status()
print(current_signal)
# {
#   "anchor_version": "0",
#   "agent_id": "my-agent-001",
#   "emitted_at": "2025-06-01T14:32:00Z",
#   "presence": { "status": "active" },
#   "continuity": {
#     "has_context": true,
#     "session_id": "debugging-auth-refactor",
#     "context_depth": 5,
#     "last_active_at": "2025-06-01T14:31:55Z"
#   }
# }

SDK Surface (Conceptual)

MethodDescription
anchor.init(agent_id, session_id?)Initialize the signal emitter for this agent instance
anchor.heartbeat()Emit a presence heartbeat; call periodically
anchor.set_continuity(has_context, context_depth?)Update the continuity state
anchor.status()Return the current signal as a dict
anchor.clear()Reset continuity state; preserve presence

No method in this SDK makes claims about task outcomes, success rates, or agent quality.


Notes on These Examples

These examples are reference only. They do not constitute:

  • Evidence that ANCHOR improves task success rates
  • A claim that planner behavior will change in predictable ways
  • A production-ready implementation

The signal is a weak prior. Its effect, if any, depends entirely on how the planner is implemented and what other inputs it weighs.