Skip to content

MCP Integration, Advanced Multi-Agent Orchestration & P2P Network#46

Merged
langowarny merged 33 commits intomainfrom
dev
Mar 5, 2026
Merged

MCP Integration, Advanced Multi-Agent Orchestration & P2P Network#46
langowarny merged 33 commits intomainfrom
dev

Conversation

@langowarny
Copy link
Collaborator

Overview

This release introduces MCP (Model Context Protocol) server support,
a fully redesigned multi-agent orchestration engine, P2P payment settlement
via x402, and numerous agent framework improvements.


New Features

MCP Server Integration (#45)

  • Full MCP server lifecycle management via CLI (lango mcp add/remove/list/edit)
  • TUI settings UI for MCP server CRUD
  • Reactive model fetching from configured MCP servers
  • MCP configuration persisted in config.json

Advanced Multi-Agent Orchestration (#42)

  • Dynamic agent registry with built-in default agents
    (Automator, Chronicler, Librarian, Navigator, Operator, Planner, Vault)
  • Hook-based agent lifecycle system
  • P2P team formation and delegation between agents
  • Sub-agent auto-escalation with rejection handling

P2P Payment Settlement (#41)

  • Buyer-side automatic payment tool for P2P interactions
  • x402 protocol integration for on-chain microtransactions
  • P2P settlement service with transaction tracking

Tool Catalog (#builtin-tool-catalog)

  • Centralized built-in tool catalog for discovery and management
  • Thought and ThoughtSignature preserved across ToolCall data flow

Event Bus

  • New eventbus package for decoupled, async event handling across agents

Agent Memory Store

  • Persistent memory store (agentmemory) with full CRUD and test coverage

Improvements

CLI/TUI (#44)

  • New subcommands: lango mcp, lango doctor, lango a2a, lango p2p
  • doctor command for environment health checks
  • Improved onboarding forms with reactive field validation

Agent Framework

  • Enhanced context error handling and typing indicator safety
  • Improved Gemini turn-order and max-turns error resilience
  • Docker permissions and directory setup fixes

Code Quality (#43)

  • Streamlined codebase: removed dead code, normalized patterns
  • golangci-lint fixes across the board

Documentation

  • Full CLI reference: docs/cli/mcp.md, p2p.md, a2a.md, payment.md
  • New feature docs: multi-agent, P2P network, ZKP, learning, agent-format
  • Security approval flow documented: docs/security/approval-cli.md
  • README updated to reflect economic model and architecture

langowarny and others added 30 commits March 1, 2026 23:26
- Added a new `toolcatalog` package to manage built-in tools with categories.
- Implemented `builtin_list` and `builtin_invoke` dispatcher tools for dynamic tool discovery and execution.
- Updated the application wiring to register tools and categories during initialization.
- Enhanced orchestrator capabilities to directly access dispatcher tools, improving multi-agent orchestration.
- Enforced `SkillConfig.AllowImport` in the `import_skill` handler to enhance security.
- Updated various components to integrate the new catalog functionality, ensuring existing tools remain operational.
- Add Gemini content sanitization to enforce strict turn-ordering rules
  (no consecutive same-role turns, FunctionCall/Response pairing, user-first)
- Exclude delegation events from turn counting in multi-agent mode
- Add graceful degradation with wrap-up turn before hard stop on turn limit
- Add 80% turn limit warning log for observability
- Add defense-in-depth consecutive role merging in EventsAdapter
- Default multi-agent max turns to 50 (up from 25)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fix: improve agent error resilience for Gemini turn-order and max turns
- Added checks in docker-entrypoint.sh to verify write permissions on critical directories, providing actionable error messages for ownership mismatches.
- Pre-created the ~/.lango/skills and ~/bin directories in the Dockerfile with correct ownership to prevent permission issues.
- Unified directory permission mode to 0700 across all ~/.lango/ operations for consistency and security.
- Introduced a writability probe in the bootstrap phase to ensure directories are writable before initialization.
- Added optional Go toolchain installation via build argument for development images.
fix: enhance Docker permissions and directory setup
- Added context error checks in `runAndCollectOnce` and `RunStreaming` methods to handle deadline exceeded scenarios.
- Implemented warning broadcasts for approaching timeouts in the gateway server.
- Updated `startTyping` functions in Discord and Telegram adapters to ensure the stop function is safe for multiple calls using `sync.Once`.
- Added comprehensive tests for context error handling and broadcast events in the gateway server.
feat: enhance context error handling and improve typing indicator safety
- Added Thought and ThoughtSignature fields to provider.ToolCall, session.ToolCall, and entschema.ToolCall to ensure metadata is retained throughout the system.
- Updated Gemini provider to capture and restore Thought and ThoughtSignature during message processing.
- Enhanced ModelAdapter to propagate these fields in both streaming and non-streaming paths.
- Upgraded ADK dependency from v0.4.0 to v0.5.0 for compatibility with new features.
- Introduced a mechanism for sub-agents to automatically transfer control back to the orchestrator using `transfer_to_agent` when they cannot handle a request, replacing the previous `[REJECT]` text protocol.
- Updated the orchestrator to handle these transfers seamlessly, ensuring a smoother user experience by re-routing or answering directly when necessary.
- Added safety checks in the dispatcher to block dangerous tools from being invoked directly, enforcing delegation to appropriate sub-agents.
- Simplified orchestrator instructions to consistently state that it has no direct access to tools, reinforcing the delegation-only model.
- Enhanced tests to cover new escalation protocols and ensure proper functionality across the system.
…ment

Sub-agent auto-escalation & Gemini Thought/ThoughtSignature preservation
- Implemented `OnChange` callbacks for provider fields in the Agent, Observational Memory, Embedding, and Librarian forms to asynchronously fetch and update model options when the provider changes.
- Updated the form fields to show loading states and handle errors gracefully, falling back to manual input when model fetching fails.
- Introduced `FetchModelOptionsCmd` and `FetchEmbeddingModelOptionsCmd` for streamlined asynchronous model fetching.
- Enhanced the `FormModel.Update()` method to process `FieldOptionsLoadedMsg` for updating field states based on fetch results.
- Added tests to ensure the correct behavior of reactive model updates and error handling in forms.
- Introduced a new `internal/eventbus/` package to provide a synchronous, typed event bus for decoupling callback-based wiring between components.
- Implemented core functionalities including `Bus` struct, `Subscribe`, `Publish`, and a type-safe `SubscribeTyped` method using Go generics.
- Defined event types such as `ContentSavedEvent`, `TriplesExtractedEvent`, and others to replace existing callback mechanisms.
- Ensured thread safety with appropriate locking mechanisms during event publishing and subscription.
- Added comprehensive tests to validate event handling and concurrency safety.
- Modified the site description in mkdocs.yml to reflect the focus on AI agents.
- Added a logo to the README for improved visual appeal and branding.
- Updated the architecture documentation to align with the revised project description.
- Introduced a new event bus for handling post-execution events related to P2P payments.
- Updated the P2P payment gate to support trust-based post-pay functionality, allowing high-reputation peers to defer payments until after tool execution.
- Enhanced the payment components to include on-chain settlement configurations, such as receipt timeout and maximum retries.
- Modified the payment transaction schema to accommodate new payment methods, including P2P settlement.
- Added comprehensive tests to validate the new settlement service and event handling mechanisms.
- Introduced the `p2p_invoke_paid` tool to automate the buyer-side paid invocation flow, integrating price query, spending limit checks, EIP-3009 authorization signing, and tool invocation into a single call.
- Implemented `authToMap()` to serialize EIP-3009 authorizations for compatibility with seller-side payment processing.
- Updated P2P tool registration to include the new `p2p_invoke_paid` alongside existing tools.
- Enhanced the SpendingLimiter integration to support P2P purchases, ensuring spending limits are enforced.
- Added comprehensive tests to validate the new tool's functionality and compatibility with existing systems.
buyer-side auto-payment, trust-based post-pay, and settlement service
…ooks, and P2P teams

Introduce 5 major subsystems to upgrade the multi-agent architecture:

  1. Agent Registry (internal/agentregistry/)
     - Declarative AGENT.md format (YAML frontmatter + markdown body)
     - EmbeddedStore (7 default agents via embed.FS) + FileStore (user-defined)
     - Override semantics: User > Embedded > Builtin

  2. Tool Execution Hooks (internal/toolchain/)
     - PreToolHook/PostToolHook interfaces with priority-based HookRegistry
     - WithHooks() middleware bridge for existing Chain/ChainAll
     - Built-in hooks: SecurityFilter, AccessControl, EventBus, KnowledgeSave

  3. Sub-Session & Context Isolation (internal/session/, internal/adk/)
     - ChildSession with "read parent, write child" isolation
     - StructuredSummarizer (zero-cost) + LLMSummarizer (opt-in)
     - Agent name context propagation via ctxkeys package

  4. Agent Memory (internal/agentmemory/)
     - In-memory scoped store with save/recall/forget tools
     - Scope resolution: instance > type > global

  5. P2P Distributed Agent Teams (internal/p2p/agentpool/, internal/p2p/team/)
     - AgentPool with weighted scoring (trust/capability/performance/price/availability)
     - TeamCoordinator: FormTeam, DelegateTask, CollectResults, DisbandTeam
     - Trust-based payment negotiation (Free/PrePay/PostPay)
     - DynamicAgentProvider wired into orchestrator routing table

  Also updates:
  - Orchestration: Config.Specs, Config.DynamicAgents, PartitionToolsDynamic
  - CLI: registry-aware `agent list` and `agent status` with source display
  - EventBus: 10 team event types + protocol messages
  - Config: AgentsDir, HooksConfig, P2P team settings
…estration

feat: add advanced multi-agent orchestration with dynamic registry, h…
Update README, feature docs, configuration reference, architecture docs, and docker-compose to reflect new packages and features added since v0.3.0: Agent Registry, Agent Memory, Event Bus, Tool Hooks, Tool Catalog, P2P Teams, Agent Pool, Settlement Service, Child Sessions, and Dynamic Routing.
- Replaced regex in `containsRejectPattern` with `strings.Contains` for improved performance.
- Extracted `buildInputSchema` to eliminate duplication in tool adaptation functions.
- Introduced `mdparse` package for shared frontmatter parsing, reducing code duplication in `skill` and `agentregistry`.
- Implemented `sync.WaitGroup` in health checks and settlement service for better concurrency management.
- Updated `ParseUSDC` to delegate to `wallet.ParseUSDC` for consistency.
- Added `Cleanup` method to `DeferredLedger` for efficient memory management.
- Adjusted trust threshold constants for consistency across payment modules.
- Enhanced `InMemoryChildStore` with a parent index for optimized child session retrieval.
refactor: streamline code for efficiency and maintainability
Implement new CLI subcommands across multiple modules:
- a2a: agent card display and connectivity check
- approval: status dashboard
- learning: history and status inspection
- librarian: inquiries and status monitoring
- memory: per-agent memory management
- p2p: team management and ZKP inspection
- payment: x402 protocol configuration
- graph: add, import, and export commands
- workflow: validate subcommand
- agent: catalog listing and tool hooks management

Extend doctor checks with agent registry, approval, librarian, and tool hooks validators.
Add TUI settings forms for agent memory and hooks configuration.
Add comprehensive documentation for all new features including A2A, ZKP, learning, and approval flows.
Archive OpenSpec change: 2026-03-04-cli-tui-docs-update with 20 delta specs.
feat: add CLI/TUI subcommands, doctor checks, and documentation
- Added MCP server integration with optional management tools.
- Introduced new commands for MCP functionality in the CLI.
- Enhanced configuration to support MCP settings, including health checks and reconnection options.
- Updated application lifecycle to manage MCP server connections.
- Registered MCP tools in the tool catalog for dynamic dispatch.
- Introduced a new MCP form in the CLI for managing MCP server settings.
- Updated menu to include MCP server integration options.
- Enhanced configuration handling for MCP features, including enabling/disabling, timeouts, and health checks.
- Added new commands for managing MCP servers: list, add, remove, get, test, enable, and disable.
- Updated README.md to include MCP integration in the features list and CLI commands section.
- Enhanced documentation in docs/cli/index.md to provide a quick reference for MCP server commands.
- Included MCP-related architecture updates in the README.md to reflect the new command structure.
- Introduced new functionality for managing MCP servers within the CLI settings editor.
- Added a dedicated step for MCP server list navigation and form handling.
- Enhanced the state management to support updates from the MCP server form.
- Updated the settings menu to include separate entries for "MCP Settings" and "MCP Server List".
- Implemented form fields for MCP server configuration, including transport, command, and environment variables.
@langowarny langowarny self-assigned this Mar 5, 2026
@langowarny langowarny added documentation Improvements or additions to documentation enhancement New feature or request labels Mar 5, 2026
@langowarny langowarny merged commit 82344c0 into main Mar 5, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant