跳到正文

wang2122

sprix-sage-router

Sprix AI at 屿智同行 — state-aware SELF/COLLABORATE/HANDOFF routing for A2A agent networks.

README 已保存到本站,可直接阅读

Documentation snapshot

README 快照

本页保存的是公开项目资料快照,阅读过程不需要连接 GitHub。

Sprix SAGE Router

State-aware agent matching for open A2A networks

图片:Tests 图片:Python 图片:License 图片:Status

An open-source research output of Sprix AI at 屿智同行.

Choose whether an agent should continue alone, recruit complementary collaborators, or hand off the task—then assign task-DAG roles, schedule dependencies, and learn from execution evidence under permission, budget, and deadline constraints.

Quick start · Algorithm · Benchmark · Contributing · Security


Why SAGE?

Agent discovery tells a system which agents exist. It does not answer the harder runtime question: who should work with whom after execution has already begun?

SAGE—State-Aware Graph Exchange—is the decision layer between A2A discovery and task execution. It evaluates three routes in one auditable objective:

RouteOwnershipBest used when
SELFIncumbent agentExisting capability and accumulated context are sufficient
COLLABORATEIncumbent retains ownershipA small complementary team covers missing requirements
HANDOFFA peer takes full ownershipSpecialist advantage exceeds context-transfer loss

SAGE is designed to sit above the Agent2Agent (A2A) protocol. A2A provides Agent Cards, messages, tasks, artifacts, authentication, and transport. SAGE decides which feasible agent configuration should execute the task, in which mode, and why.

flowchart LR
    A["Task DAG + live execution state"] --> B["A2A Agent Cards + live bids"]
    B --> C{"Permission, budget,deadline, availability"}
    C -->|eligible| D["SELF and HANDOFF"]
    C -->|eligible| E["Beam-search COLLABORATE teams"]
    D --> F["Role assignment + DAG schedule"]
    E --> F
    F --> G["Contextual success model + utility"]
    G --> H["Inspect decision, topology, and constraints"]
    H --> I["Partial outcomes + actual cost/latency"]
    I --> J["Skill trust + synergy + bid fidelity update"]
    J --> B

What makes SAGE different?

  • Mid-execution tri-mode routing. SELF, COLLABORATE, and HANDOFF compete in the same utility function instead of relying on disconnected heuristics.
  • Progress-aware replanning. Active executors, completed DAG nodes, failures, accumulated progress, and transferable context affect whether switching is worthwhile.
  • Complementarity before prestige. A team is rewarded for marginal requirement coverage, not for collecting individually high-ranked but redundant agents.
  • Contextual trust instead of one reputation score. Reliability is learned per agent and per requirement, so success in coding does not automatically imply strength in research.
  • Task-DAG role assignment. Every remaining requirement is assigned to an executor; dependency edges become an inspectable communication topology and critical-path latency estimate.
  • Learned outcome model. A regularized online predictor replaces the original fixed success equation and can later be swapped for a production reward model.
  • Bounded team search. Beam search compares multiple team prefixes instead of committing to one greedy sequence.
  • Bid fidelity. Quoted confidence, cost, and latency are calibrated against observed execution evidence.
  • Permission-first matching. Ineligible agents never enter the ranking, regardless of predicted quality.
  • Evidence-aware credit. Per-requirement and per-agent outcomes avoid giving every teammate identical full credit.
  • Auditable output. Every decision includes assignments, topology, success, coverage, cost, latency, risk, utility, and a human-readable rationale.

Core algorithm

For task requirement (r), SAGE combines global and requirement-conditioned trust into calibrated capability (q_{a,r}). Team coverage is:

$$ C_r(S)=1-\prod_{a\in S}(1-q_{a,r}) $$

Each requirement is assigned to the strongest calibrated team member. SAGE schedules these assignments over the requirement DAG, serializing work assigned to one agent and parallelizing independent work assigned to different agents. Team-level cost and critical-path latency are checked again after construction.

Every feasible route is ranked by:

$$ U(m,S,z,E)=V\hat p_\theta(y=1\mid x,m,S,z,E)-\lambda_c C-\lambda_l L-\lambda_r R-\lambda_h H-\lambda_o O-\lambda_u\mathcal U+\beta\mathcal B $$

Here (z) is role assignment, (E) is the induced communication topology, (H) is context-transfer loss, (O) is coordination overhead, and (\mathcal U/\mathcal B) support uncertainty-aware exploration. The full design and limitations are documented in ALGORITHM.md.

Quick start

The reference implementation requires Python 3.10+ and has no runtime dependencies.

git clone https://github.com/wang2122/sprix-sage-router.git
cd sprix-sage-router
python demo.py

Run the verification suite:

python -m unittest -v
python benchmark.py

Minimal usage:

from sprix_sage import Agent, ExecutionOutcome, Requirement, SAGERouter, Task

agents = [
    Agent("planner", {"planning": 0.92, "coding": 0.55}, cost=0.08, latency_ms=900),
    Agent("coder", {"planning": 0.35, "coding": 0.96}, cost=0.12, latency_ms=1200),
]

task = Task(
    "build-feature",
    requirements=(
        Requirement("planning", 0.4),
        Requirement("coding", 0.6, depends_on=("planning",)),
    ),
    value=1.0,
    budget=0.30,
    deadline_ms=4000,
    progress=0.35,
)

router = SAGERouter(agents, incumbent_id="planner")
decision = router.route(task)
print(decision.mode, decision.assignments, decision.topology)

# Feed back the strongest available evidence after execution.
router.record_outcome(
    decision,
    ExecutionOutcome(
        success=0.9,
        requirement_scores={"planning": 0.95, "coding": 0.86},
        actual_cost=0.19,
        actual_latency_ms=1450,
    ),
)

A2A integration

Production integration maps protocol and marketplace signals into SAGE as follows:

A2A or marketplace signalSAGE representation
AgentCard.skillsNormalized capability vector
Security requirementsHard permissions eligibility filter
Supported input/output modesCompatibility filter before scoring
Task status, artifacts, and failuresExecutionState, completed DAG nodes, and transfer loss
Provider quoteBid(cost, latency, confidence)
Completed task evaluationContextual trust, pair residual, success model, and bid-fidelity updates

The current prototype returns a routing decision; it intentionally does not transmit tasks. An A2A client can execute the selected route through message/send, streaming, task polling, or cancellation.

Benchmark

benchmark.py runs 2,500 tasks over five deterministic seeds in an external simulator. Hidden capability, pair effects, nonlinear quality, realized cost, and realized latency are deliberately different from SAGE’s prediction model. Values are mean ± population standard deviation across seeds:

StrategyQualityCommon utilityCost / budgetDeadline miss
Incumbent only0.507 ± 0.0030.389 ± 0.0020.239 ± 0.00526.4%
Advertised-skill solo0.558 ± 0.0050.435 ± 0.0050.292 ± 0.00411.9%
Feasible solo oracle0.553 ± 0.0050.440 ± 0.0050.271 ± 0.0050.0%
Static SAGE0.591 ± 0.0070.467 ± 0.0070.329 ± 0.0070.0%
Online SAGE0.634 ± 0.0060.487 ± 0.0060.434 ± 0.0110.2%

All strategies are evaluated with the same external quality-cost-latency utility. Online SAGE spends more than static SAGE to obtain higher simulated quality; that trade-off remains visible instead of being hidden behind a capability-only score.

[!IMPORTANT] These synthetic numbers test learning and constraints without using SAGE’s own score as ground truth. They are still not evidence of real-world superiority. A publishable evaluation requires confidence intervals over real executions, strong learned-routing baselines, heterogeneous agent benchmarks, marketplace trace replay, calibration analysis, and adversarial conditions.

Repository map

PathPurpose
sprix_sage.pyContextual router, DAG scheduler, beam search, and online updates
ALGORITHM.mdFormal objective, search, credit assignment, and limitations
demo.pyReadable end-to-end routing example
benchmark.pyExternal nonlinear simulator and common-utility baselines
test_sprix_sage.pyBehavioral unit tests
.github/workflows/tests.ymlMulti-version continuous integration

Roadmap

  • Signed Agent Card ingestion and capability normalization
  • Requirement-conditioned trust and online success prediction
  • Requirement DAG assignment and team-level deadline checks
  • Evidence-aware partial credit and quote-fidelity learning
  • Learned task-text embeddings and candidate retrieval
  • Real A2A adapters for discovery, execution, streaming, and cancellation
  • Offline replay on anonymized Sprix marketplace traces
  • Adversarial-bid, churn, privacy, and policy-violation evaluation
  • Distributed router service with observability and human approval gates

Research foundations

Project status

SAGE is an early-stage research preview, not a production SLA or a peer-reviewed result. Version 0.2 adds a genuinely learned but deliberately lightweight policy layer; it is not a substitute for real trace training or causal off-policy evaluation. Production deployment requires calibrated evaluators, authenticated identities, signed capability metadata, privacy and security review, persistent event-driven recovery, monitoring, and task-specific validation.

About Sprix AI

Sprix AI is the A2A initiative of 屿智同行, focused on agent discovery, task matching, multi-agent scheduling, and transaction mechanisms for dependable agent-to-agent service exchange. Sprix SAGE Router is an open-source algorithmic research output of that initiative.

Company attribution describes the project’s origin; this public repository remains a research preview and does not expose proprietary production systems or data.

Team & project leadership

  • Yonghao Zhang — CEO of 屿智同行; Master’s degree in Computer Science from Tsinghua University.
  • Yichen Wang — CTO of 屿智同行; Sprix AI project lead and SAGE algorithm designer.

Additional community contributions are credited through their commits, pull requests, and the repository’s contributors graph.

Community and governance

We welcome technically grounded issues and pull requests. Please read CONTRIBUTING.md, follow the Code of Conduct, and report vulnerabilities according to SECURITY.md.

If you use this design in academic work, cite the repository metadata in CITATION.cff.

License

Released under the MIT License. Copyright © 2026 Sprix AI at 屿智同行.

Official distribution

获取与安装

暂未发现可确认的官方软件包地址

当前 README 快照没有出现 npm、PyPI、Crates.io、pub.dev 等官方包页链接。本站不会根据仓库名称猜测下载地址。

本站不托管项目文件;需要安装时,请以项目维护者发布的官方文档为准。

使用前核验

本站保存公开资料用于阅读,不代表安全审计或功能背书。安装前请核对许可证、依赖来源和发布签名,不要直接运行来源不明的二进制文件或高权限脚本。