Skip to main content

Extraction Inventory — Twenty / Agno → @agentkit

What we extract, from where (pinned to a source commit), the target @agentkit package, and the dependency edges that block a clean lift — each with a proposed neutral port. Analysis only.

Sources (pinned)

SourceRepoCommitRole
ShareFlow AI backendRise-Experts/social_shareai_backend/731c93feThe running Agno runtime being replaced
TwentyRise-Experts/twenty454be88b71Architectural patterns (not a running agent)
Twenty appsRise-Experts/twenty-apps163ec22How the social app consumes the runtime

Naming follows Agno's concepts; the target structure follows Twenty's layered module layout, which the @agentkit package map already mirrors.

Agno runtime → @agentkit (file-level)

ai_backend/app/assistant/ — orchestration

Agno fileConceptTarget packageExtract vs rebuild
agent.pyAgno Agent build (history, deps)runtime + agentsrebuild (drop num_history_runs)
factory.pyassistant factory / compositionruntime (composition root)rebuild
specialists.py, studio.pymulti-agent Team, per-role specialistsagents (versioned manifests)rebuild as declarative manifests
context.pycontextvars (workspace_id, user_id)core ExecutionContextrebuild (explicit, passed not global)
dependencies.pydeps injected into runcontext providersrebuild
auth.py, middleware.pyrequest auth / middlewareauthorization + transport (graphql)rebuild
db.py, db_skills.pypersistence + workspace skillspersistence + skillsextract logic, re-port storage
skills.pyskill loading (LocalSkills)skillsrebuild on the skills port
tools.py@tool defs (generate_content, search_web)tools (+ ShareFlow integration)rebuild on the tool registry
llm_resolve.pymodel resolutionmodelsrebuild

ai_backend/app/agents/ — the specialist team + adapters

Agno fileConceptTarget packageNotes
planner_agent, writer, tailor, reply, researcher, quality, visionspecialist agentsagents manifests + runtimeShareFlow-specific manifests live in the integration
model.pycomplete() provider adapter, LlmOverridemodels (provider factory)rebuild on Vercel AI SDK
memory.pyget_agno_db() → Agno PostgresDb/InMemoryDbpersistence (SessionStateStore)AVOID Agno session pattern (see gaps)
tools.pyagent toolstoolsrebuild

ai_backend/app/llm/, core/, schemas/

Agno fileConceptTarget package
llm/registry.pyLlmOverride, SUPPORTED_PROVIDERS (pure data, no SDK)models (registry)
llm/agno_factory.pybuild Agno model per providermodels (provider factory)
core/browser,capture,readpage,readpdf,makepdf,safefetch,websearchweb/pdf/vision utilitiesfiles / documents / pdf / rag + research tools
core/config.pysettingscomposition/config
schemas/api.pyrequest/response contractsgraphql

ai_backend/skills/ — built-in skills (ShareFlow-specific)

analytics-reporting, document-generation, mermaid-diagrams, platform-media-rules, post-composition, publishing-safety, research-and-citation → the skill-loading mechanism goes to skills; the skill content is ShareFlow's and lives in the integration. Note: db_skills.py already enforces TEXT-ONLY workspace skills (no executable code) — matches the platform rule "arbitrary skill scripts disabled by default".

Twenty patterns → @agentkit

Twenty sourcePatternTarget
twenty-server/src/modules/workflow/workflow-executor, workflow-toolsstep/tool execution, status machineruntime + tools
twenty-server/src/modules/dashboard/toolstool descriptor shapetools
twenty-sdk / twenty-client-sdk (graphql-sse)transport, subscriptions over SSEgraphql + the SSE adapter (SPEC #27)

Blocking dependency edges → proposed neutral port

Blocking coupling (Agno/Twenty)Why it blocksProposed neutral port
Agno Agent(db=…) binds runtime to Agno's DBcan't swap storagepersistence stores + SessionStateStore
contextvars global request contexthidden global, not tenant-safe by constructionexplicit ExecutionContext (host-built)
num_history_runs=20 history injectiontoken bloat + failuresbudgeted context (docs/03) + compaction (docs/13)
SUPABASE_DB_URL / Supabase wiring in memory.pyprovider lock-inpersistence (Postgres/Supabase adapters) + BlobStore
LlmOverride + agno_factory tie to Agno modelsprovider lock-inmodels registry + provider factory (Vercel AI SDK)
Agno Team routing by role stringframework-specificdeclarative agents manifests + runtime router

Gap notes (keep vs avoid)

  • Context window (AVOID). Agno uses add_history_to_context=True, num_history_runs=20 — a fixed, model-unaware window plus manual token pointers. Replace with model-registry limits + per-section budgets + pruning (docs/03).
  • Session handling (AVOID). Agno sessions via get_agno_db re-inject 20 turns and drop the rest (no summarization). Replace with session state + versioned thread-summary compaction (docs/13).
  • Retry (KEEP). Agno's retry is the pattern worth carrying over — reimplemented Claude-style (backoff+jitter, honor retry-after, transient classes only, bounded attempts) and made safe by idempotency keys (docs/04). Now specified and surfaced to the frontend.