{"id":50663620,"url":"https://github.com/sqliteai/adam","last_synced_at":"2026-06-08T04:04:45.850Z","repository":{"id":356568972,"uuid":"1185410249","full_name":"sqliteai/adam","owner":"sqliteai","description":"An embeddable cross-platform AI agent library written in C. Cloud and local LLMs, tool calling, long-term memory, voice, sessions, research mode, self-evolving loops. The SQLite of agent frameworks: small, portable, just works.","archived":false,"fork":false,"pushed_at":"2026-05-18T13:55:10.000Z","size":3391,"stargazers_count":72,"open_issues_count":1,"forks_count":10,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-18T15:36:22.494Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://sqlite.ai","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sqliteai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-18T14:55:55.000Z","updated_at":"2026-05-15T21:42:11.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/sqliteai/adam","commit_stats":null,"previous_names":["sqliteai/adam"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sqliteai/adam","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqliteai%2Fadam","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqliteai%2Fadam/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqliteai%2Fadam/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqliteai%2Fadam/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sqliteai","download_url":"https://codeload.github.com/sqliteai/adam/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqliteai%2Fadam/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34047294,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-08T04:04:45.048Z","updated_at":"2026-06-08T04:04:45.844Z","avatar_url":"https://github.com/sqliteai.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Adam\n\nEmbeddable AI agent library in C.\n\nAdam gives you a complete agent loop: tool calling, memory, sessions, voice, streaming, structured output, in one `#include`. Works with cloud APIs (Anthropic, OpenAI, Google Gemini, Groq, Together, xAI) and local models (llama.cpp) through the same interface. Compiles on macOS, Linux, Windows, iOS, Android, and WASM.\n\n## Quick Start\n\n```c\n#include \"adam.h\"\n\nint main(void) {\n    adam_init();\n\n    adam_settings_t *s = adam_create_settings();\n    adam_settings_set_provider(s, ADAM_API_ANTHROPIC,\n                               getenv(\"ANTHROPIC_API_KEY\"),\n                               \"claude-sonnet-4-20250514\");\n\n    adam_history_t *h = adam_history_create();\n    adam_run_result_t r = adam_run(s, h, \"What is the capital of France?\");\n\n    printf(\"%s\\n\", r.final_response);  // \"The capital of France is Paris.\"\n\n    adam_run_result_free(\u0026r);\n    adam_history_destroy(h);\n    adam_settings_destroy(s);\n    adam_cleanup();\n}\n```\n\n```bash\nmake deps    # build llama.cpp + whisper.cpp\nmake all     # build libadam.a\nmake test    # run 161 tests (ASan + UBSan)\n```\n\n## Features\n\n| Feature | Description |\n|---------|-------------|\n| **Agent loop** | Tool calling with automatic iteration until final response |\n| **Three providers** | Anthropic, OpenAI, Google Gemini + any compatible API + local GGUF via llama.cpp |\n| **Local vision** | Multimodal image understanding via llama.cpp + mmproj (Gemma 3, LLaVA, etc.) |\n| **Image generation** | Native image output via Gemini image models (gemini-3.1-flash-image-preview) |\n| **Database extensions** | [SQLite](extensions/sqlite/) and [PostgreSQL](extensions/postgres/) extensions — embed Adam as SQL functions that query the same database |\n| **13 built-in tools** | File I/O, shell, calculator, SQL, web fetch/search, HTTP POST, memory, research, multi-agent |\n| **Long-term memory** | Hybrid BM25 + vector search via SQLite (sqlite-memory + sqlite-vector) |\n| **Session persistence** | Save/load conversations with UUIDv7 keys |\n| **Telegram bot** | Full-featured [Telegram integration](examples/telegram/) with text, voice, images, tools, and memory |\n| **Voice** | STT (Whisper cloud/local) + TTS (cloud/system) + full audio pipeline |\n| **Streaming** | Real-time token delivery via callback |\n| **Structured output** | `adam_run_json()` with validation and retry |\n| **Evolution loop** | Self-improving agent: iterate, score, refine strategy |\n| **Research mode** | Autonomous multi-iteration information gathering with report synthesis |\n| **Multi-agent** | Agent A invokes Agent B as a tool, with independent settings/tools |\n| **Guardrails** | Pre-send and post-receive validation callbacks |\n| **Response cache** | LRU hash table keyed on model + message history |\n| **History management** | Clone, summarize (LLM-based compression), token estimation |\n| **Thread pool** | Concurrent agent execution with job queue |\n| **Filesystem sandbox** | Tools restricted to explicitly allowed directories |\n| **Cross-platform** | macOS, Linux, Windows, iOS, Android, WASM (Emscripten) |\n| **Arena allocator** | Zero-leak per-iteration memory with automatic cleanup |\n\n## Build\n\n```bash\nmake deps          # Build llama.cpp, whisper.cpp (+ mbedtls/curl on Linux)\nmake all           # Build libadam.a\nmake test          # Build \u0026 run unit tests (ASan + UBSan)\nmake chat          # Interactive text chat (cloud API)\nmake chat GGUF=models/model.gguf  # Interactive text chat (local)\nmake vision GGUF=models/model.gguf MMPROJ=models/mmproj.gguf  # Local vision test\nmake talk          # Voice agent (cloud)\nmake talk LOCAL=1  # Voice agent (fully local)\nmake memory        # Memory system tests\nmake clean         # Remove all build artifacts\n```\n\n## API Reference\n\nFull API documentation with every function, type, and callback: **[API.md](API.md)**\n\n## Examples\n\n```c\nadam_settings_t *s = adam_create_settings();\nadam_settings_set_provider(s, ADAM_API_ANTHROPIC, api_key, \"claude-sonnet-4-20250514\");\n\nadam_history_t *h = adam_history_create();\nadam_run_result_t r = adam_run(s, h, \"Explain quantum entanglement simply.\");\nprintf(\"%s\\n\", r.final_response);\nadam_run_result_free(\u0026r);\n\n// Continue the conversation — history carries forward\nr = adam_run(s, h, \"Can you give an analogy?\");\nprintf(\"%s\\n\", r.final_response);\nadam_run_result_free(\u0026r);\n\nadam_history_destroy(h);\nadam_settings_destroy(s);\n```\n\nMore examples are available in the **[examples/](examples/)** directory:\n\n| Example | Description |\n|---------|-------------|\n| [simple-conversation](examples/simple-conversation/) | Multi-turn chat with a cloud API |\n| [tool-calling](examples/tool-calling/) | Register a custom tool and let the agent call it |\n| [local-model](examples/local-model/) | Run a local GGUF model via llama.cpp |\n| [local-vision](examples/local-vision/) | Image understanding with a local vision model + mmproj |\n| [google-gemini](examples/google-gemini/) | Use Google Gemini models |\n| [image-generation](examples/image-generation/) | Generate images with Gemini |\n| [sqlite-query](examples/sqlite-query/) | Natural language queries on any SQLite database |\n| [structured-json](examples/structured-json/) | Get validated JSON output with retry |\n| [memory](examples/memory/) | Long-term memory with hybrid BM25 + vector search |\n| [sessions](examples/sessions/) | Save and restore conversations |\n| [streaming](examples/streaming/) | Real-time token streaming via callback |\n| [voice](examples/voice/) | Speech-to-text + agent + text-to-speech pipeline |\n| [multi-agent](examples/multi-agent/) | Agent A delegates to Agent B as a tool |\n| [evolution](examples/evolution/) | Self-improving agent with scoring loop |\n| [research](examples/research/) | Autonomous multi-iteration research with report |\n| [filesystem-sandbox](examples/filesystem-sandbox/) | File and shell tools restricted to allowed directories |\n| [guardrails](examples/guardrails/) | Pre-send and post-receive validation |\n| [response-cache](examples/response-cache/) | LRU cache for repeated queries |\n| [thread-pool](examples/thread-pool/) | Concurrent agent execution |\n| [telegram](examples/telegram/) | Telegram bot with text, images, tools, and memory |\n| [wasm-chat](examples/wasm-chat/) | Browser-based chat UI via WebAssembly |\n| [full-agent](examples/full-agent/) | All features combined |\n\n## Database Extensions\n\nAdam can be embedded directly inside SQLite and PostgreSQL as a SQL extension. The agent can query the **same database** it's loaded in — ask questions in natural language, get answers from your data.\n\n```sql\n-- SQLite\n.load adam\n\n-- PostgreSQL\nCREATE EXTENSION adam;\n\n-- Configure (both)\nSELECT adam_config('provider', 'anthropic');\nSELECT adam_config('api_key', 'sk-ant-...');\n\n-- Ask about your data — the agent reads the schema and runs SQL\nSELECT adam_ask('How many users signed up last month?');\n-- → \"47 users signed up last month.\"\n\n-- Generate SQL without executing\nSELECT adam_sql('top 5 products by revenue');\n-- → \"SELECT p.name, SUM(oi.quantity * oi.price) AS revenue FROM ...\"\n```\n\n| Function | Description |\n|----------|-------------|\n| `adam_config(key, val)` | Configure provider, API key, model (persisted) |\n| `adam(msg)` | Stateless one-shot chat |\n| `adam_ask(msg)` | SQL-aware agent — reads schema, queries data, multi-turn |\n| `adam_sql(question)` | Generate SQL from natural language |\n| `adam_create_session()` | Create session (auto-created on first `adam_ask`) |\n| `adam_get_session()` | Get current session UUID |\n| `adam_clear_session()` | Clear session and history |\n\nSee **[extensions/sqlite/](extensions/sqlite/)** and **[extensions/postgres/](extensions/postgres/)** for build instructions.\n\n## Architecture\n\n```\nadam_run() loop:\n  build system prompt (identity + instructions + bootstrap files + memory + datetime)\n  -\u003e check guardrails (on_before_send)\n  -\u003e check cache\n  -\u003e dispatch LLM (mock | local/llama.cpp | remote/HTTP)\n  -\u003e check guardrails (on_after_receive)\n  -\u003e if tool_calls: execute tools -\u003e append results -\u003e loop\n  -\u003e if text: return final response -\u003e auto-save session -\u003e extract memory\n```\n\n**Platform abstraction**: macOS uses NSURLSession, Linux uses libcurl+mbedtls, WASM uses embedder-provided `http_fn` callback.\n\n**Memory management**: Arena allocators for per-iteration zero-copy work. malloc/free for long-lived structures. Arena-allocated strings are only valid within the current iteration.\n\n## Feature Gates\n\nDefine before `#include \"adam.h\"` to disable features:\n\n| Gate | Effect |\n|------|--------|\n| `ADAM_NO_CURL` | No libcurl (must provide `http_fn` callback) |\n| `ADAM_NO_LOCAL` | No llama.cpp (no local inference) |\n| `ADAM_NO_PTHREADS` | No thread pool, no voice thread |\n| `ADAM_NO_SQLITE` | No SQLite (no memory, sessions, or SQL tool) |\n| `ADAM_NO_VOICE` | No voice subsystem |\n| `ADAM_NO_FILESYSTEM` | No file_read/file_write/list_directory tools |\n| `ADAM_NO_SHELL` | No shell_exec tool |\n\n## Dependencies\n\nAll vendored as git submodules in `modules/`:\n\n| Module | Purpose |\n|--------|---------|\n| llama.cpp | Local LLM inference + GGML compute |\n| whisper.cpp | Local speech-to-text (shares ggml via symlink) |\n| miniaudio | Cross-platform audio I/O |\n| sqlite | Amalgamation build |\n| sqlite-memory | Hybrid BM25 + vector knowledge store |\n| sqlite-vector | Vector similarity search |\n| mbedtls | TLS (Linux only) |\n| curl | HTTP (Linux only) |\n\nmacOS uses system frameworks (Foundation, Security, Metal, AVFoundation, Accelerate) instead of curl/mbedtls.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqliteai%2Fadam","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsqliteai%2Fadam","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqliteai%2Fadam/lists"}