@@ -342,6 +342,82 @@ async fn main() {
342342}
343343```
344344
345+ #### 🤝 Collaborative Multi-Provider Agent (SDK: ` col ` feature)
346+
347+ Attach a [ ` CollabPool ` ] to ` AutoGPT ` so the orchestrator executes agents
348+ sequentially in round-robin provider order. Each entry in ` agents![...] `
349+ corresponds to one entry in the pool's provider list.
350+
351+ ``` rust
352+ use autogpt :: prelude :: * ;
353+
354+ #[tokio:: main]
355+ async fn main () {
356+ let persona = " Lead Architect" ;
357+ let behavior = " Design a microservices architecture for an e-commerce platform." ;
358+
359+ let pool = CollabPool :: from_providers (vec! [
360+ " gemini" . to_string (),
361+ " openai" . to_string (),
362+ ]);
363+
364+ let agent_a = ArchitectGPT :: new (persona , behavior ). await ;
365+ let agent_b = ArchitectGPT :: new (persona , behavior ). await ;
366+
367+ let autogpt = AutoGPT :: default ()
368+ . with (agents! [agent_a , agent_b ])
369+ . with_collab_pool (pool )
370+ . build ()
371+ . expect (" Failed to build AutoGPT" );
372+
373+ match autogpt . run (). await {
374+ Ok (response ) => println! (" {}" , response ),
375+ Err (err ) => eprintln! (" Agent error: {:?}" , err ),
376+ }
377+ }
378+ ```
379+
380+ > [ !NOTE]
381+ > ** How it works** : ` AutoGPT::run() ` picks a random starting provider via
382+ > [ ` CollabSelection::Random ` ] , then executes each agent in the ` agents![...] `
383+ > list sequentially mapped to pool providers in round-robin order.
384+ > Enable ` CollabSelection::Explicit(name) ` to always start from a specific
385+ > provider.
386+
387+ #### 🧠 Agent Metacognition SDK (` mta ` feature)
388+
389+ The ` mta ` feature embeds a [ ` MetacognitionEngine ` ] inside every [ ` AgentGPT ` ]
390+ that records task outcomes and injects strategy context into prompts.
391+
392+ ``` rust
393+ use autogpt :: prelude :: * ;
394+
395+ #[tokio:: main]
396+ async fn main () {
397+ let persona = " Research Analyst" ;
398+ let behavior = " Summarise research papers." ;
399+
400+ let mut agent = AgentGPT :: new_borrowed (persona , behavior );
401+
402+ agent . record_task_outcome (" parse pdf" , " success" , 0 );
403+ agent . record_task_outcome (" extract sections" , " failed" , 2 );
404+
405+ println! (" {}" , agent . metacognition_context ());
406+ println! (" Should adjust? {}" , agent . should_adjust_strategy ());
407+ }
408+ ```
409+
410+ | Method | Description |
411+ | --------------------------------------------- | --------------------------------------------------- |
412+ | ` record_task_outcome(task, outcome, retries) ` | Record a task result and generate an insight entry |
413+ | ` metacognition_context() ` | Returns the LLM-injectable strategy context string |
414+ | ` should_adjust_strategy() ` | ` true ` when the engine recommends a strategy change |
415+ | ` consecutive_failures() ` | Number of consecutive failing tasks |
416+
417+ The engine triggers automatically inside ` GenericAgent ` every 3 tasks or
418+ after 2+ consecutive failures, querying the LLM to produce strategy
419+ adjustments. The TUI status bar shows ** MetaCognizing** during this phase.
420+
345421## 🛠️ CLI Usage
346422
347423The CLI provides a convenient means to interact with the code generation ecosystem. The ` autogpt ` crate bundles two binaries in a single package:
@@ -501,6 +577,35 @@ This opens a conversational AI shell where you can:
501577- Press ` ESC ` to interrupt a running generation.
502578- Type ` exit ` or ` quit ` to save the session and close.
503579
580+ #### 🤝 Collaborative Multi-Provider Mode (` --collab ` , requires ` col + cli ` )
581+
582+ Collab mode spawns one ` GenericAgent ` per configured provider (all providers
583+ with an API key set in the environment) and distributes the task across them
584+ in round-robin order with per-model fallback:
585+
586+ ``` sh
587+ # Build with collab support:
588+ cargo run --features " cli,col,gem,oai,xai" --bin autogpt -- --collab
589+
590+ # Or install:
591+ cargo install autogpt --features " cli,col,gem,oai"
592+ autogpt --collab
593+ ```
594+
595+ ** Provider discovery** : Any provider feature compiled in whose API key env var
596+ is set at runtime is automatically added to the pool (e.g. ` GEMINI_API_KEY ` ,
597+ ` OPENAI_API_KEY ` , ` XAI_API_KEY ` ).
598+
599+ ** Fallback behaviour** :
600+
601+ | Event | Action |
602+ | --------------------------------- | --------------------------------------------- |
603+ | Rate-limit / quota error | Rotate to next model within the same provider |
604+ | All models for provider exhausted | Remove provider from pool, route to next |
605+ | All providers exhausted | Log ` ⚠ All collab providers exhausted. ` |
606+
607+ The TUI logs the active pool and each routing step with ` 🤝 ` /` 🔀 ` prefixes.
608+
504609#### ⚡ Direct Prompt Mode
505610
506611For a quick one-shot non-interactive prompt:
0 commit comments