Skip to content
asadullah48Public

About

Multi-agent editorial pipeline that verifies its own output: real Flesch readability scoring, dossier-grounded fact-checking, and a bounded Editor-to-Writer revision loop. Runs with no API key; Ollama and Gemini optional.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

πŸ“° CollabX: Multi-Agent Editorial Team for High-Impact Newsletters & Reports

An orchestrated multi-agent framework coordinating specialized Researcher, Writer, and Editor agents in a collaborative state graph to produce publication-ready newsletters.

The interesting part is not that it calls a model. It is that it does not trust one.

CollabX scores every draft it produces: real Flesch Reading Ease against a per-tone floor, every statistic and quotation traced back to a source dossier, and a bounded Editor β†’ Writer revision loop that sends failing drafts back with the specific critique that failed them. Those gates run identically whether the prose came from a language model or from the built-in template engine.

Important

It runs with no API key, no model, and no network. That is the default. git clone, pip install -e ., uvicorn β€” and it works. A model is an opt-in upgrade (free options below), never a requirement, because a project you cannot run is a screenshot.

What it does, in one request

curl -X POST localhost:8014/api/v1/editorial/produce-newsletter \
  -H 'Content-Type: application/json' -d '{"topic":"Agent Workforces"}'

The Researcher assembles a dossier, the Writer drafts from it, and the Editor scores the result and sends it back for revision if it fails a gate:

Readability (Flesch Reading Ease) is 53.7 against a 55 floor for
  'Engaging Storyteller'. Short by 1.3 points.
Fact-check: 3 of 3 checkable claims trace to the research dossier.
Tone alignment with 'Engaging Storyteller' is 0.92 against a 0.75 floor.
Sources: built-in sample fixture, identical for every topic. Not real research.
Editorial loop: 1 revision round applied, all gates passing at publication.

Every number there is measured from the draft. None of them is a constant.

Live demo CI License: Apache 2.0 Python 3.10+ No API key required Author


πŸš€ What CollabX Provides

  1. Specialized Multi-Agent Roles β€” three separable stages with distinct responsibilities and a typed hand-off between each:
    • ResearcherAgent: produces a ResearchDossier of findings and core themes.
    • WriterAgent: produces an ArticleDraft β€” headline, hook, and structured sections.
    • EditorAgent: produces a PublishedNewsletter with feedback and compiled HTML.
  2. Typed Editorial Domain Model: eight Pydantic models (EditorialBrief, ResearchDossier, ArticleDraft, EditorFeedback, PublishedNewsletter, …) that define the contract between stages and the shape of the API response.
  3. Single-Call Pipeline with a Revision Loop: POST /api/v1/editorial/produce-newsletter runs Researcher β†’ Writer β†’ Editor and returns the complete edition in one response. The Editor acts as a gate: a draft that misses its readability, grounding, or tone gate is sent back to the Writer under tighter limits. The loop is bounded and stops when the gates pass, the budget is spent, or a round changes nothing. The endpoint is total. If the budget runs out with gates still failing, the edition is still returned, carrying revision_required: true and a critique naming each failing gate and its margin.
  4. Deterministic Output: identical briefs produce identical editions and identical IDs across processes, which makes the pipeline straightforward to test.
  5. Interactive Editorial Studio: glassmorphic bilingual (English/Arabic RTL) dashboard that submits a brief and renders the returned edition, research signals, and the editor's critique notes.
  6. Deployment Manifests: Dockerfile, Compose service, and a Helm chart with liveness/readiness probes wired to /healthz and /readyz.

🧭 Implemented vs. Not Yet Implemented

Capability Status
Typed models & stage hand-off βœ… Implemented
FastAPI gateway, health probes, static dashboard βœ… Implemented
Docker / Compose / Helm packaging βœ… Implemented
Deterministic, reproducible edition IDs βœ… Implemented
HTML escaping in html_body βœ… Implemented β€” text nodes are escaped, so a topic carrying markup cannot become live HTML
Flesch Reading Ease scoring βœ… Implemented β€” computed from the draft in core/readability.py
Fact-check grounding against the dossier βœ… Implemented β€” statistics and quotations only, see the caveat below
Tone alignment scoring βœ… Implemented β€” sentence length and long-word density against a per-tone profile
Editor β†’ Writer revision loop βœ… Implemented β€” bounded, and reports how many rounds it used
Brief-driven output (tone, target_word_count) βœ… Implemented β€” tone drives headline, hook, register and the readability floor; word count drives elaboration depth
Topic-drift detection βœ… Implemented β€” warns when the dossier shares no vocabulary with the brief topic
Markdown β†’ HTML compilation ⚠️ Block-level only β€” no inline formatting (**bold** is not converted), no lists
Fact-check coverage ⚠️ Statistics and quotations only. A confidently wrong prose sentence passes: verifying it needs semantic matching, not string comparison
Word-count target ⚠️ Reported, never gated. The Writer composes from the dossier and will not pad to hit a number
Pluggable model providers βœ… Implemented β€” Ollama (local, free), Gemini (free tier), or none. Zero vendor SDKs: every provider is plain HTTP via the standard library
Caller-supplied research βœ… Implemented β€” POST your own dossier and the fact-check verifies against sources this system did not write
Source provenance labelling βœ… Implemented β€” every response says whether research was CALLER_SUPPLIED, MODEL_GENERATED, or the built-in FIXTURE
Automatic web research ❌ Not implemented β€” a model cannot browse. Model-drafted findings are labelled unverified and are never given fabricated source URLs

What the scores do and do not mean

  • readability_score is a real Flesch Reading Ease value. The gate is per tone, not global. A single 80.0 threshold was unreachable: FRE 80–89 is 6th-grade reading level, while this newsletter's stated audience is "CTOs, Founders & Enterprise Architects", which is the 30–59 band.
  • fact_check_passed means no unsupported statistic or quotation was found. A draft containing no figures and no quotations has nothing to check, and the critique notes say so explicitly rather than implying verification happened.
  • tone_alignment_score is two structural proxies, not a judgement of voice. A draft can score 1.00 and still sound wrong.
  • Provenance decides what any of it is worth. The Editor verifies the Writer against the dossier, so the fact-check is only as good as the research behind it. Against a model-generated dossier, fact_check_passed: true means the Writer copied the Researcher faithfully β€” nothing about the world. Every response says which case it is, in plain language.

πŸ”Œ Running it with a model (free)

Three ways, none of which cost anything:

Setup Key Cost
Deterministic (default) nothing none free
Ollama ollama pull llama3.2 none free, local, offline
Gemini free key GEMINI_API_KEY free tier
COLLABX_PROVIDER=ollama uvicorn collabx.server:app --port 8014
COLLABX_PROVIDER=gemini uvicorn collabx.server:app --port 8014

curl -s localhost:8014/api/v1/providers   # which engine is live (never echoes a key)

If a provider is unreachable, out of quota, or returns something unusable, the request falls back to the deterministic engine and still succeeds. A missing model degrades the quality of the output, never the availability of the service.

Making the fact-check mean something

Post your own research and the gate verifies against sources CollabX did not write. This is the mode the project is actually for:

curl -X POST localhost:8014/api/v1/editorial/produce-newsletter \
  -H 'Content-Type: application/json' -d '{
    "topic": "Regional Dairy Pricing Volatility",
    "dossier": {
      "dossier_id": "D1",
      "topic": "Regional Dairy Pricing Volatility",
      "findings": [{
        "headline": "Farmgate prices swung sharply in Q3",
        "statistic": "Farmgate milk prices moved 12% between July and September.",
        "source_url": "https://example.gov/dairy/q3-report",
        "verified_quote": "Processors absorbed most of the volatility."
      }],
      "core_themes": ["Dairy pricing volatility"]
    }
  }'

SPEC.md describes the target design. The revision loop and quality gates it specifies are now built; LLM-backed agents are not.


πŸ›οΈ CollabX Architecture

                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚     Editorial Brief     β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚     ResearcherAgent     β”‚
                    β”‚  β€’ Statistics & Quotes  β”‚
                    β”‚  β€’ Core Themes          β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚       WriterAgent       β”‚
                    β”‚  β€’ Catchy Hooks         β”‚
                    β”‚  β€’ Long-Form Narrative  β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚       EditorAgent       β”‚
                    β”‚  β€’ Readability Scoring  β”‚
                    β”‚  β€’ HTML Compilation     β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Quick Start

# 1. Clone repository
git clone https://github.com/asadullah48/collabx.git
cd collabx

# 2. Install the package plus test dependencies
pip install -e ".[dev]"

# 3. Run automated test suite
python -m pytest tests -v

# 4. Start local gateway & frontend editorial studio
uvicorn collabx.server:app --host 127.0.0.1 --port 8014 --reload

No API key, no model download, no configuration. Step 4 serves a working editorial desk.

Live demo

https://collabx-gamma.vercel.app β€” no signup, no key, nothing to install.

The hosted build runs the deterministic engine on purpose. A public URL holding an API key is one crawler away from an exhausted quota, and a demo that returns 500 is worse than no demo. This one cannot break and costs nothing to keep up. Run it locally with a free model to see the LLM path.

Hugging Face Spaces, Render and Fly are covered in DEPLOY.md.


πŸ§ͺ How this is verified

Claims in this README are checked, because an earlier version of this project carried a "200+ tests" badge over a suite of 10 tautological ones.

  • 152 tests, run by CI on Python 3.10–3.13, Linux and Windows.
  • The wheel is installed to a clean prefix and run from outside the source tree on every CI run. The suite passes whether or not packaging works, because pytest imports from the working directory β€” this repository has already shipped a build that was broken while every test passed.
  • The API is booted and hit with real HTTP requests in CI, not just TestClient.
  • Every quality feature is mutation-tested. Reverting readability scoring, grounding, tone scoring, the per-tone floors, the revision loop, HTML escaping, or span protection each turns tests red. A test that still passes with the feature removed is decoration.
  • CI never calls a model (COLLABX_PROVIDER=deterministic), so runs are hermetic: no key, no network, no flake.

πŸ€– Agentic AI Alignment

  • Autonomy β€” Researcher β†’ Writer β†’ Editor produce a publication-ready newsletter with no human drafting or fact-checking step required.
  • Resilience β€” the Editor's gates (Flesch readability floor, source-traced statistics, a bounded revision loop) run identically whether the prose came from a model or the built-in template engine β€” the quality guarantee doesn't depend on the LLM being available or even present, which is why it runs with no API key by default.
  • Adaptivity β€” the revision loop sends failing drafts back with the specific critique that failed them, so the Writer adapts its next draft to concrete feedback rather than blindly regenerating.

Roadmap

  • Expose the Researcher/Writer/Editor trio as MCP tools so other content-ops agent systems can plug into this same verified pipeline.
  • Extend the Kubernetes deployment path (helm/) already documented with autoscaling per role as newsletter volume grows.

πŸ€– Author

Built by Asadullah Shafique.

πŸ”— Explore my portfolio showcasing Agentic AI projects and real-world applications: asadullahshafique-devunity.vercel.app

🌐 Connected Ecosystem & Portfolio

About

Multi-agent editorial pipeline that verifies its own output: real Flesch readability scoring, dossier-grounded fact-checking, and a bounded Editor-to-Writer revision loop. Runs with no API key; Ollama and Gemini optional.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages