diff --git a/docs/plans/agentscope-integration.md b/docs/plans/agentscope-integration.md new file mode 100644 index 0000000..95d397a --- /dev/null +++ b/docs/plans/agentscope-integration.md @@ -0,0 +1,356 @@ +# AgentScope integration for Diffbot: plan + +> **Status:** plan only. Written 2026-12-03. **Audience:** the implementer (πŸ› ) and Andrew (πŸ…°). +> This PR adds no code, no scaffold, no package, and no published artifacts. Nothing here has been posted to `agentscope-ai/agentscope`, `agentscope-ai/agentscope-samples`, `agentscope-ai/docs`, PyPI, or any hub. +> Sources, raw findings, quotes, and things that could not be verified: [agentscope-research-notes.md](./agentscope-research-notes.md). +> Sibling plans: [Langflow](./langflow-integration.md) (conventions reused here), [Microsoft Agent Framework](./microsoft-agent-framework-integration.md), [Dependabot audit](./dependabot-audit.md). + +Legend: πŸ…° Andrew must act or approve Β· πŸ›  implementer Β· πŸ…Ή Jerome (only where a Diffbot API fact needs confirming) + +--- + +## 0. TL;DR + +- **Ship a Diffbot-owned PyPI package, `agentscope-diffbot`** (import `agentscope_diffbot`), published by Diffbot (`Diffbot `) from a new repo `diffbot/agentscope-diffbot`. Andrew creates the repo; it does not exist yet. AgentScope has no plugin registry or entry-point mechanism for tools. Users install the package and pass its tools to `Toolkit(tools=[...])`. That is the documented way to add any tool, and the one third-party vendor package we found (`agentscope-datacircle`) works the same way. +- **Target AgentScope 2.x only** (`agentscope>=2.0.3,<3`, Python β‰₯3.11). The current release is 2.0.12 (2026-11-16). The 1.x line stopped at 1.0.21 (2026-05-25). The often-linked `doc.agentscope.io` tutorial documents **v1.0** (`register_tool_function`, `preset_kwargs`), which 2.x no longer uses. The current docs are at `docs.agentscope.io/en/versions/2.0.12/…`. +- **v0.1 = 7 read-only, synchronous, single-request tools**, each a `ToolBase` subclass: Web Search, Page Extract, Organization Search, Person Search, News Search, KG DQL Query, and LLM Ask. Organization Enhance and Person Enhance are **deferred** (decided 2026-12-02, same as Langflow and n8n). Every tool sets `is_read_only = True` and `is_concurrency_safe = True`, and its `check_permissions` returns `ALLOW`. This follows the docs' own `WebSearch` example: the agent can call these tools without a confirmation prompt, while deny and ask rules still apply. +- **Reuse the official SDK as-is.** Depend on `diffbot>=3.4.1,<4` and use `DiffbotAsync`. All 7 operations map to `web_search`, `extract`, `dql`, and `ask` / `ask_json`, so **no SDK change is needed**. The structured Org, Person, and News DQL builders, with escaping, live in the integration. +- **Auth:** the token is a constructor argument (`DiffbotTools(token=...)` β†’ `DiffbotAsync(token=...)`). AgentScope's `agentscope.credential` classes cover model providers only, not tools. The documented pattern for vendor keys is the application reading its own env var or secret store and passing the value in. Never call `resolve_token()` and never read `~/.diffbot/credentials`. +- **Upstream into AgentScope core: no.** Core built-in tools are coding and system tools only (Bash, file tools, tasks, AskUser), and the one open PR adding a web-search built-in (#2931) has sat unreviewed since 2026-09-28. **AgentScope's hubs don't apply:** the MCP Hub lists MCP servers and the Skill Hub lists `SKILL.md` skills, so neither distributes Python tools. A later sample in `agentscope-samples` is optional and needs Andrew's go. +- **Gate:** Andrew creates `diffbot/agentscope-diffbot` and sets up PyPI trusted publishing. Until then, the M1 spike runs locally with no repo and no publish. + +--- + +## 1. AgentScope requirements (as of 2026-12-03) + +**Official repo:** `github.com/agentscope-ai/agentscope`. `modelscope/agentscope` now redirects there; the GitHub API returns `agentscope-ai/agentscope` for both names. Licence Apache-2.0. **Current stable:** `agentscope` **2.0.12** on PyPI (2026-11-16), with `main` at `2.0.13dev`. `requires-python >=3.11`. + +### 1.1 Sources actually opened + +| # | Title | URL | +| --- | --- | --- | +| 1 | Tool tutorial (legacy site, **v1.0**) | https://doc.agentscope.io/tutorial/task_tool.html | +| 2 | Tool overview (2.0.12) | https://docs.agentscope.io/en/versions/2.0.12/building-blocks/tool/overview (source: `agentscope-ai/docs` `en/versions/2.0.12/building-blocks/tool/overview.mdx`) | +| 3 | Python Tool (2.0.12) | https://docs.agentscope.io/en/versions/2.0.12/building-blocks/tool/python-tool | +| 4 | Meta Tool / tool groups (2.0.12) | https://docs.agentscope.io/en/versions/2.0.12/building-blocks/tool/manage-tools | +| 5 | MCP (2.0.12) | https://docs.agentscope.io/en/versions/2.0.12/building-blocks/tool/mcp | +| 6 | MCP Hub (2.0.12) | https://docs.agentscope.io/en/versions/2.0.12/deploy/hub/mcp-hub | +| 7 | Skill Hub (2.0.12) | https://docs.agentscope.io/en/versions/2.0.12/deploy/hub/skill-hub | +| 8 | Repo metadata, tree, branches, and releases | https://github.com/agentscope-ai/agentscope | +| 9 | `CONTRIBUTING.md` | https://github.com/agentscope-ai/agentscope/blob/main/CONTRIBUTING.md | +| 10 | `src/agentscope/tool/` (`__init__.py`, `_base.py`, `_toolkit.py`, `_adapters.py`, `_tool_group.py`, `_response.py`, `_types.py`) | https://github.com/agentscope-ai/agentscope/tree/main/src/agentscope/tool | +| 11 | `src/agentscope/permission/` (`_engine.py`, `_types.py`) | https://github.com/agentscope-ai/agentscope/tree/main/src/agentscope/permission | +| 12 | `src/agentscope/credential/` (`_base.py`, `_openai.py`) | https://github.com/agentscope-ai/agentscope/tree/main/src/agentscope/credential | +| 13 | `src/agentscope/agent/_agent.py` (`Agent.__init__`) | https://github.com/agentscope-ai/agentscope/blob/main/src/agentscope/agent/_agent.py | +| 14 | `pyproject.toml` | https://github.com/agentscope-ai/agentscope/blob/main/pyproject.toml | +| 15 | PR #2931 "add WebSearch and Python builtin tools" (open) | https://github.com/agentscope-ai/agentscope/pull/2931 | +| 16 | `agentscope-samples` tree and `deep_research/agent_deep_research/main.py` (Tavily via MCP) | https://github.com/agentscope-ai/agentscope-samples | +| 17 | `agentscope-runtime` tree (ModelStudio search tools plus an AgentScope tool adapter) | https://github.com/agentscope-ai/agentscope-runtime | +| 18 | `agentscope-bricks` (archived) | https://github.com/agentscope-ai/agentscope-bricks | +| 19 | Third-party package `agentscope-datacircle` (repo and PyPI) | https://github.com/waynehamadi/agentscope-datacircle Β· https://pypi.org/project/agentscope-datacircle/ | +| 20 | PyPI JSON for `agentscope`, `agentscope-runtime`, `agentscope-bricks`, `agentscope-diffbot` (404), and other guessed vendor names (all 404) | https://pypi.org/pypi/agentscope/json | +| 21 | Official MCP Registry entry `io.github.diffbot/diffbot-mcp` | https://registry.modelcontextprotocol.io/v0/servers?search=diffbot | + +### 1.2 Requirements that shape the design + +- **Tool protocol (2.x).** A tool is any `ToolBase` subclass (`agentscope.tool`). It declares the class attributes `name`, `description`, `input_schema` (JSON Schema), `is_concurrency_safe`, and `is_read_only`. It implements `async check_permissions(tool_input, context) -> PermissionDecision` and `async call(**kwargs) -> ToolChunk | AsyncGenerator[ToolChunk, None]`. Do not override `__call__`, which runs the middleware chain (2, 3, 10). +- **Registration.** `Toolkit(tools=[...], tool_groups=[...], mcps=[...], skills_or_loaders=[...])`, or `await toolkit.add_tool(tool, group_name="basic")`. Tools in the reserved `"basic"` group are always exposed. Each extra `ToolGroup(name, description, instructions, tools=...)` becomes a boolean on the auto-registered `reset_tools` meta tool, which the agent uses to activate groups. `Agent(name, system_prompt, model, toolkit=...)` takes the toolkit as "the sole source" of tools (4, 10, 13). +- **Duplicate names overwrite.** `add_tool` logs "Duplicate tool name … overwriting it" and replaces the existing tool (10). Tool names must therefore be namespaced (`diffbot_*`). +- **`FunctionTool` defaults to ASK.** "Wrapped functions default to `ASK` permission behavior: the user must explicitly allow each call. Subclass `ToolBase` directly when you need custom permission logic" (3). This is the main reason to subclass `ToolBase` rather than wrap functions. +- **Read-only fast path.** On `main` (and since at least v2.0.8), the permission engine auto-allows any invocation whose `check_read_only()` is `True` in every mode, after deny and ask rules (11). The docs' mode table still says DEFAULT mode asks unless an allow rule matches (Β§1.3). Returning `ALLOW` from `check_permissions` as well makes behaviour the same on both. +- **Results.** A tool returns a `ToolChunk(content=[TextBlock|DataBlock], state=…, metadata={…})`. On error it sets `state=ToolResultState.ERROR`. `Toolkit.call_tool` accumulates chunks into a `ToolResponse`, so "the tool functions only need to return/yield the ToolChunk objects in an incremental manner" (10). Streaming is first-class: `call` may be an async generator. +- **Async.** `ToolBase.call` is `async`, which matches `DiffbotAsync` directly. **`call` as the override point appeared in v2.0.3.** In v2.0.0–2.0.2, `__call__` was the method to override (`_base.py` at tags). This sets the floor of `agentscope>=2.0.3`. +- **Credentials.** `agentscope.credential.CredentialBase` subclasses (OpenAI, Anthropic, DashScope, and others) must implement `get_chat_model_class()` and similar methods. They are tied to models, and there is no tool-credential type (12). Docs and samples pass vendor keys directly: an `HttpMCPConfig(headers={"Authorization": "Bearer xxx"})` (5), and `env={"TAVILY_API_KEY": os.getenv("TAVILY_API_KEY", "")}` (16). +- **Dependencies and imports.** Python `>=3.11` (14). CONTRIBUTING enforces lazy imports for optional deps in core (9). That rule only matters if we ever upstream. +- **No tool plugin mechanism.** The repo has no `entry_points` group and no tool registry. A GitHub code search for `entry_points` in the repo returns nothing (8, 14). Distribution means "pip install, then import". + +### 1.3 What changed recently (docs vs repo; repo is ground truth) + +- [x] **Two doc sites.** `doc.agentscope.io` (the task's starting URL) still serves the **v1.0** tutorial. It uses `toolkit.register_tool_function(fn, preset_kwargs={"api_key": "xxx"})`, `ToolResponse`-returning functions, `create_tool_group` / `update_tool_groups`, and `reset_equipped_tools`. None of these is the 2.x API. The 2.x docs live at `docs.agentscope.io` (PyPI's "Documentation" URL), sourced from the `agentscope-ai/docs` repo. +- [x] **The repo moved** from `modelscope/agentscope` to `agentscope-ai/agentscope` (redirect). +- [x] **`preset_kwargs`** survives only as a stale docstring in `_types.py` and `Toolkit.get_tool_schemas`. There is no registration API for it in 2.x. Secrets go into the tool's constructor instead. +- [x] **Read-only handling.** The docs' `PermissionMode` table (and `permission/_types.py`) says DEFAULT mode asks for Read/Glob/Grep unless a rule allows them. `_engine.py` on `main` has a shared `_check_read_only_fast_path` "auto-allowed in every PermissionMode", and the MCP doc says `readOnlyHint` tools "in DEFAULT … still ASK". We follow the docs' `WebSearch` example and return `ALLOW` explicitly, so the outcome doesn't depend on which description is right. +- [x] **`ToolBase.call`** exists from v2.0.3. Before that (2.0.0–2.0.2), tools overrode `__call__`. `agentscope-datacircle` carries a shim for this. +- [x] **v1 is frozen in practice.** There is a `v1` branch, but the last 1.x release on PyPI is 1.0.21 (2026-05-25), the same day as 2.0.0. + +--- + +## 2. Scope + +### 2.1 First ship (v0.1): 7 read-only, synchronous, single-request tools + +| Tool name (model-visible) | Class | Diffbot endpoint | SDK today | +| --- | --- | --- | --- | +| `diffbot_web_search` | `DiffbotWebSearch` | `GET llm.diffbot.com/api/v1/web_search` (`text`, `size`, `snippetLength`, `maxTokens`; Bearer) | `web_search()` βœ… | +| `diffbot_extract` | `DiffbotExtract` | `GET api.diffbot.com/v3/{analyze\|article\|product\|discussion\|job\|image\|video\|list\|event}` (`url`, `timeout`); Markdown via `analyze` + `mode=llm` | `extract(url, api, fmt)` βœ… | +| `diffbot_organization_search` | `DiffbotOrganizationSearch` | `POST kg.diffbot.com/kg/v3/dql`, `type:Organization` built from name, homepage, industry, city/country, employee/revenue ranges, public/private | `dql()` βœ… + builder (integration) | +| `diffbot_person_search` | `DiffbotPersonSearch` | DQL `type:Person` from name, employer, title, city/country | `dql()` βœ… + builder | +| `diffbot_news_search` | `DiffbotNewsSearch` | DQL `type:Article` from mentions, text, title, publisher, language, since/until | `dql()` βœ… + builder | +| `diffbot_kg_query` | `DiffbotKGQuery` | `POST kg/v3/dql` with raw query, `size`, `from` | `dql(query, size=, from_=)` βœ… | +| `diffbot_llm_ask` | `DiffbotLLMAsk` | `POST llm.diffbot.com/rag/v1/chat/completions` (`diffbot-small-xl`, SSE, optional `response_format` json_schema) | `ask()` / `ask_json()` βœ… | + +Verified in this checkout (`diffbot` 3.4.1): `DiffbotAsync(token: str, …)` raises `ValidationError` on an empty token and does not call `resolve_token()`. It exposes `extract`, `ask`, `ask_json`, `web_search`, `dql`, `dql_parallel`, `crawl*`, `account`, `verify_token`, `entities`, `nlp`, ontology helpers, and `request()`. There are no structured DQL builders and no Enhance wrapper (`grep -i enhance src/diffbot` finds only a comment in `types.py`). + +All 7 are read-only, single-request, and suit agent tool calls. + +### 2.2 Deferred, with reasons + +| Capability | Why deferred | +| --- | --- | +| Organization Enhance, Person Enhance | **Deferred from v0.1 (Andrew accepted 2026-12-02).** This matches Jerome's 2026-11-17 view that Enhance is "bloat for the LLM", and matches Dify's scope. No SDK Enhance wrapper is needed. Revisit only if users ask for enrichment. Nothing about AgentScope argues otherwise. | +| Crawl (`crawl*`) | An async, multi-minute job. A single tool call would block the ReAct loop. AgentScope has a background/external-execution pattern (`is_external_tool`), but that hands execution to a human or external system, which doesn't fit. Revisit as a start/poll pair if asked. | +| Bulk Enhance | Async job plus polling, the same problem as crawl. | +| Account / usage as a tool | Not an agent task. `verify_token()` may back a `DiffbotTools.check()` helper for app developers, which is not model-visible. | +| Ontology fetch as a tool | Metadata, not data. The builders embed field enums instead. | +| NLP / entities | Not in the n8n / Langflow v0.1 surface. Parity first. | +| Streaming Ask tokens as incremental `ToolChunk`s | AgentScope supports async-generator tools, so streaming is cheap. v0.1 still returns one chunk to keep the tests simple. The M1 spike checks whether streaming shows up usefully in the AgentScope console or web UI (Q6). | +| A `DiffbotCredential` class | `CredentialBase` is model-oriented (Β§1.2). Subclassing it for a tool would misuse the type. | +| Model provider (Diffbot LLM as a `ChatModelBase`) | A different contract: per CONTRIBUTING it needs a credential, model card YAML, and two formatters, and lands in core. "Ask" as a tool is enough for v0.1. | + +--- + +## 3. Dependency decision: reuse the `diffbot` SDK + +**Decision: depend on `diffbot>=3.4.1,<4` and use `DiffbotAsync`.** Do not hand-roll HTTP. No SDK release is needed for v0.1. + +Why: + +- `ToolBase.call` is `async` (1.2), and `DiffbotAsync` mirrors every method we need. No thread offloading is required, unlike `agentscope-datacircle`, which runs a sync GET via `asyncio.to_thread`. +- The SDK already handles the details we'd otherwise duplicate: Bearer vs `token=` auth per host, `snippetLength=FULL` β†’ `rerank=none`, Markdown extract via `mode=llm`, the DQL JSON body, SSE parsing and tool-call-leak checks in `ask`, `json_schema_format`, retries, timeouts, and typed errors. +- Small footprint: `httpx` (already an `agentscope` dependency), `click`, and `rich`. +- Python compatibility: the SDK supports `>=3.9` and AgentScope `>=3.11`, so the package declares `requires-python >=3.11`. + +Gaps and how to close them: + +| Gap | Decision | +| --- | --- | +| Structured DQL builders + escaping | **Live in the integration** (`agentscope_diffbot/_dql.py`, with table tests). This is the same decision as Langflow. The field mapping is integration UX. Promote it to the SDK only if a second Python consumer needs it, and even then as a separate, Andrew-approved change. | +| Token resolution | Pass the token explicitly to `DiffbotAsync(token=…)`. Never call `resolve_token()`: its fallback to `DIFFBOT_API_TOKEN` / `~/.diffbot/credentials` reads machine-local state from whatever process hosts the agent. In AgentScope's multi-user Agent Service, that would leak one operator's token to every user. | +| User-Agent attribution | The SDK sends `diffbot-python/`, and there is no option to extend it. v0.1 ships with that. A distinct UA suffix is open question Q7, and would be a separate SDK option that doesn't block v0.1. | + +--- + +## 4. Tool design + +### 4.1 Seven tools vs one toolkit tool + +**Recommendation: seven focused `ToolBase` subclasses, plus a small factory that returns them, plus an optional `ToolGroup` helper.** + +- AgentScope's unit of model-visible behaviour is one `ToolBase` with one `input_schema` (2, 3). A single "diffbot" tool with an `operation` enum would give the model a union of unrelated arguments. The n8n and Langflow designs split for the same reason. +- `ToolGroup` is AgentScope's native way to bundle related tools that "can be activated or deactivated as a unit" (4). Offering a ready-made `diffbot` group gives agents with many tools a cheap way to hide Diffbot until it's needed. It's optional, and users who want the tools always-on pass the list to `Toolkit(tools=...)`. +- Separate classes let `is_read_only`, permissions, and descriptions be tuned per tool. They also let a future Enhance tool be added without touching the others. + +### 4.2 Layout + +- Distribution `agentscope-diffbot` β†’ import package `agentscope_diffbot` (src layout, hatchling, `py.typed`), matching `agentscope-runtime` / `agentscope_runtime` and `agentscope-datacircle` / `agentscope_datacircle` (Β§5). +- `src/agentscope_diffbot/`: + - `__init__.py` exports the 7 classes, `DiffbotTools`, and `__version__`. + - `_client.py`: a shared `DiffbotAsync` holder, plus error mapping that never echoes the token. + - `_dql.py`: builders and escaping. + - `_base.py`: `DiffbotToolBase(ToolBase)`, which sets `is_read_only = True` and `is_concurrency_safe = True`, makes `check_permissions` return `PermissionDecision(behavior=ALLOW, …)`, and formats results. + - One module per tool. +- `pyproject.toml`: `requires-python >=3.11`; dependencies `agentscope>=2.0.3,<3` and `diffbot>=3.4.1,<4`; authors `Diffbot `; licence MIT (Q2). There are no entry points, because AgentScope has none to register with. + +### 4.3 User-facing API (sketch for the implementer, not code to ship in this PR) + +- `DiffbotTools(token: str, *, timeout: float = 30.0, include_kg_query: bool = False)`: + - `.tools()` returns a list of tool instances that share one client. + - `.tool_group(name="diffbot")` returns a `ToolGroup` with a description and usage `instructions`. + - `await .close()` closes the client. `DiffbotTools` is also an async context manager. +- Each tool class can also be built on its own: `DiffbotWebSearch(token=...)`. +- Usage in the README: `Toolkit(tools=DiffbotTools(token=os.environ["DIFFBOT_API_TOKEN"]).tools())`, then `Agent(..., toolkit=toolkit)`. The other form is `Toolkit(tool_groups=[diffbot.tool_group()])`. +- **KG Query is opt-in** (`include_kg_query=False` by default), because models write poor DQL. The class is still exported for power users. The default is open question Q4. + +### 4.4 Auth and credentials + +- **The token is a required constructor argument.** The package never reads `~/.diffbot/credentials` and never calls `resolve_token()`. +- **Recommended setup (README):** the application reads `DIFFBOT_API_TOKEN` from its own environment or secret manager and passes it in. This is the same pattern AgentScope's samples use for vendor keys (`os.getenv("TAVILY_API_KEY")`) and the same pattern its docs use for MCP headers (5, 16). +- **Env fallback:** if `token` is omitted, `DiffbotTools` *may* read `os.environ["DIFFBOT_API_TOKEN"]` directly and raise a clear error when it's unset. It would read the env var only, never the file. This convenience is open question Q3. The default recommendation is to require the argument explicitly, which is safest for AgentScope's multi-user Agent Service. +- The token is never part of any `input_schema`, so it is never model-visible. Error messages and `ToolChunk.metadata` never contain it. + +### 4.5 Inputs, outputs, permissions + +- **`input_schema`**: hand-written JSON Schema (or Pydantic `ParamsBase` models exported via `model_json_schema()`, which AgentScope provides to strip `title`) (10). Keep it small: + - Web Search: `query` and an optional `num_results`. + - Extract: `url` and an optional `page_type` enum. + - Org / Person / News: a few structured fields, with enums for industry, country, language, public/private, and size buckets. + - Ask: `question` and an optional `json_schema`. + - KG Query: `query`, `size`, and `from`. + + Numeric knobs not meant for the model (`timeout`, `max_tokens`) are constructor options, not schema fields. +- **Descriptions are the routing signal.** Make them concrete about what Diffbot is good at. For example: "Find companies in the Diffbot Knowledge Graph by name, website, industry, location or size. Returns firmographics." +- **Output:** one `ToolChunk` with a `TextBlock`: + - Search and KG results: compact JSON text, with long fields trimmed to a configurable character budget. + - Extract: the Markdown body plus title and URL. + - Ask: the answer text, or JSON when a schema is given. + + The full structured result goes in `ToolChunk.metadata`, which is "accessed within the agent" without re-parsing. +- **Errors:** map `diffbot.errors` to `ToolChunk(state=ToolResultState.ERROR, content=[TextBlock("Diffbot returned 401: check the Diffbot API token")])`, so the model can recover and retry. Don't raise for API errors. Do raise for programmer errors such as a missing token at construction. +- **Permissions:** `is_read_only = True`, so the engine's read-only fast path auto-allows these tools in every mode on current `main`. `check_permissions` also returns `ALLOW`, as the docs' `WebSearch` example does, so older 2.0.x versions behave the same. User-configured deny and ask rules still take precedence. Whether calls that spend Diffbot credits should default to ASK instead is open question Q5. + +### 4.6 Structured search β†’ DQL (injection-safe) + +- Free-text values become quoted DQL string literals with `\` and `"` escaped. They are never concatenated as raw clauses. Newlines are rejected or normalised. +- Enumerated fields are validated against fixed lists. These are the same lists as the JSON Schema `enum`, so the model sees them too. +- Numbers are range-checked. `since`/`until` are parsed as ISO-8601 and re-serialised. +- Exact DQL field names come from the n8n v0.1 implementation, the same source the Langflow plan uses. πŸ…Ή confirms them only if that source and the current ontology disagree. +- Table tests include hostile inputs: `foo" OR type:Person`, backslashes, unicode, and empty strings. + +### 4.7 Client lifecycle + +- `DiffbotTools` creates one `DiffbotAsync` lazily on first call and shares it across its tools. That's safe because the tools are concurrency-safe and `httpx.AsyncClient` supports concurrent requests. +- `close()` / `async with` let app developers release it. The README shows both. +- *To verify in the M1 spike:* that a lazily created client is safe across AgentScope Agent Service requests, which may run on one event loop or on several. If not, fall back to creating a client per call (`async with DiffbotAsync(...)`). + +### 4.8 Icons + +Not applicable. AgentScope's Python tools have no icon field. Hub entries have an `icon_url`, but hubs don't distribute Python tools (Β§5.4). + +### 4.9 Testing + +- **Unit tests (offline, always):** pytest + `pytest-asyncio`. Use `DiffbotAsync(transport=httpx.MockTransport(...))` (the SDK accepts a `transport`), or patch the client at the module. + - Each tool's `input_schema` validates as JSON Schema. + - `await Toolkit(tools=…).get_tool_schemas()` lists all 7 (or 6, without KG Query) names. + - `await tool(**kwargs)` returns a `ToolChunk` with the expected text, metadata, and state. + - Errors produce `state=ERROR`, and the token never appears in output or logs. + - `check_permissions` returns `ALLOW`, and `check_read_only` returns `True`. +- **DQL builder table tests**, including the injection cases above. +- **Agent smoke test (CI):** an `Agent` with a scripted or fake chat model that emits one tool call per tool, to confirm the tools work inside the ReAct loop under the DEFAULT permission mode. *M1 checks* whether AgentScope ships a test or mock model we can use. If it doesn't, a minimal `ChatModelBase` stub is acceptable in tests. +- **Version matrix:** the floor (`agentscope==2.0.3`) and the latest 2.x, on Python 3.11–3.13. A weekly job also runs against `main` of `agentscope` to catch API drift. +- **Live tests (manual or scheduled, opt-in):** a few calls using a repo secret `DIFFBOT_API_TOKEN`. Never on fork PRs. + +### 4.10 CI + +GitHub Actions in the Diffbot-owned repo: + +- `tests.yml` runs on push and PR: `uv sync --frozen`, ruff, pyright, and pytest across the matrix. +- Dependabot follows the cross-repo policy in [dependabot-audit.md](./dependabot-audit.md): allow-list `diffbot` on uv, plus monthly grouped github-actions. `agentscope` stays out of the allow list. No floor bumps unless needed. + +### 4.11 Docs + +- README covering: + - Install: `pip install agentscope-diffbot` or `uv add agentscope-diffbot`. + - Token setup. + - The `Toolkit(tools=…)` and `ToolGroup` forms. + - One section per tool. + - Permission notes: read-only, auto-allowed, and how to add an ask rule if wanted. + - A full example agent: Web Search + Extract + Organization Search. + - An "already using MCP?" note pointing to `diffbot-mcp` as an alternative (Β§5.2). +- Link the README from this repo's README only after the first release (separate PR, Andrew's call). + +### 4.12 Release and publish + +- Copy Diffbot's usual `release.yml` from this repo: tag-triggered, **PyPI trusted publishing (OIDC)** with no stored token, plus a `workflow_dispatch` dry run. +- **No RC process.** `agentscope-diffbot` is a new PyPI package with no dependent repos. Under Diffbot's policy, RC tags are for npm packages whose dependents need syncing. It ships a stable `0.1.0` directly once Andrew gives the go. AgentScope imposes no publishing requirements of its own: no registry, no provenance requirement. +- SemVer 0.x until tool names and schemas settle. Tool `name`s are the model-facing contract, so renaming one is a breaking change. +- Author `Diffbot `, MIT licence (confirm, Q2). No paid listing tiers. + +--- + +## 5. Peer comparison and distribution path + +### 5.1 Search / extract / KG analogues in the AgentScope ecosystem + +| Peer | Where | Shape | Auth | Notes | +| --- | --- | --- | --- | --- | +| **Core built-ins** | `agentscope.tool` | `Bash`, `PowerShell`, `Read`, `Write`, `Edit`, `Glob`, `Grep`, `Task*`, `AskUser` | n/a | **No web search, extract, or KG tool in core.** Built-ins are local/coding tools. | +| **Docs' `WebSearch` example** | Python Tool page (3) | `ToolBase` subclass, `is_read_only = True`, `check_permissions` β†’ `ALLOW`, `call` β†’ `ToolChunk` | not shown | The pattern we copy. | +| **PR #2931** (DuckDuckGo `WebSearch` built-in) | core, **open** since 2026-09-28 | built-in tool | none (keyless) | Unreviewed. The repo's PR-guard bot flagged it for not linking an issue. Evidence that core doesn't readily take search tools. | +| **Tavily** in `agentscope-samples` deep research | samples repo | **MCP**: `StdIOStatefulClient(… "tavily-mcp@latest" …, env={"TAVILY_API_KEY": os.getenv(...)})` | env var passed by the app | The official samples consume vendor search through MCP, not a Python package. | +| **ModelStudio Search / SearchLite** | `agentscope-runtime` (`agentscope_runtime.tools.searches`) with an `agentscope_tool_adapter` | Alibaba first-party components adapted to AgentScope, LangGraph, and AutoGen | DashScope key | First-party only. The runtime repo was last pushed 2026-06-04. 2.x compatibility not verified. | +| **`agentscope-bricks`** | archived 2026-01 | ModelStudio search components | β€” | Archived, so not a model to follow. | +| **`agentscope-datacircle`** (third party) | PyPI + `waynehamadi/agentscope-datacircle` | 4 read-only `ToolBase` subclasses plus a `tools()` factory; also supports 1.x via `register(toolkit)` | keyless API | **Closest structural peer:** a vendor-style `agentscope-` package, `ToolBase` subclasses that return `ALLOW`, used via `Toolkit(tools=…)`. Only one such package was found, so this is weak evidence and only one data point. | +| **AgentScope Java Harness** (`web_search` / `web_fetch`, Tavily) | `agentscope-java` | built-in, opt-in (PR #4103) | `TAVILY_API_KEY` | Java only, out of scope. Shows the Java line is moving web tools to opt-in. | + +### 5.2 Diffbot already reachable via MCP + +`diffbot-mcp` is listed in the **official MCP Registry** as `io.github.diffbot/diffbot-mcp` (v0.2.1). It has a PyPI stdio package and a remote `https://mcp.diffbot.com/mcp` endpoint. AgentScope users can already connect it with `MCPClient(..., mcp_config=HttpMCPConfig(url=..., headers={"Authorization": "Bearer …"}))` (5). + +**Why a native package anyway:** + +- The tools are typed and read-only, so they are auto-allowed. The MCP doc says MCP tools with `readOnlyHint` still ASK in DEFAULT mode, and the engine code disagrees (Β§1.3). +- No stdio subprocess, and no dependency on a remote MCP endpoint. +- Structured, injection-safe Org/Person/News search, which matches the n8n and Langflow surface. +- Native `ToolGroup` support. + +Whether the GitHub MCP Registry (the one `GitHubMCPHub` reads) lists `diffbot-mcp` was **not verified**: the search parameter didn't filter. Any listing work belongs to `diffbot-mcp`, not this plan. + +### 5.3 How vendors package for AgentScope + +- AgentScope-owned packages use `agentscope-` β†’ `agentscope_` (`agentscope-runtime`, `agentscope-bricks`). +- The one third-party vendor-style package uses the same shape (`agentscope-datacircle`). +- No PyPI or GitHub policy reserving the `agentscope-` prefix was found. CONTRIBUTING doesn't mention third-party packages. +- Vendors mostly reach AgentScope through MCP (Tavily in samples). No vendor-maintained search/extract package for AgentScope was found on PyPI: `agentscope-{tavily,exa,firecrawl,serpapi,brightdata,jina,apify,composio,…}` are all 404. So Diffbot would be early, with little precedent either way. + +**Name recommendation: `agentscope-diffbot`** (import `agentscope_diffbot`). It follows the framework's own `agentscope-*` naming and the one vendor peer, and `agentscope-diffbot` is unclaimed on PyPI (404, checked 2026-12-03). It also mirrors the Langflow choice of framework prefix + `diffbot` (`lfx-diffbot`). The alternative `diffbot-agentscope` (also 404) would sort with Diffbot packages but goes against the AgentScope-side precedent. + +--- + +### 5.4 Distribution: where the tools live + +**Recommendation: (1) a Diffbot-owned `agentscope-diffbot` package on PyPI.** + +| Option | Verdict | Why | +| --- | --- | --- | +| **1. Diffbot-owned PyPI package** (`agentscope-diffbot`, repo `diffbot/agentscope-diffbot`) | βœ… **Primary** | This is how any tool reaches an AgentScope agent: construct `ToolBase` instances and pass them to `Toolkit` (2, 3). No plugin registry or entry point exists, so a package is all that's needed. Diffbot controls releases and fixes, there's no coupling to AgentScope's release cadence, and no outward PR is needed to ship. The only vendor-style peer does exactly this. | +| **2. Upstream into `agentscope-ai/agentscope` core** (`agentscope.tool`) | ❌ Not now | Core built-ins are local/coding tools only. CONTRIBUTING has no guide for adding tools and says that for other modules contributors should "open an issue first so we can coordinate". It also says "Don't add dependencies casually", so a `diffbot` dependency is a hard sell. The only web-search built-in PR (#2931) is unreviewed after two months. Credentials in core are model-only. This would be an outward issue/PR that needs Andrew's go, with a low chance of acceptance. | +| **3. AgentScope hubs** (MCP Hub, Skill Hub) | ❌ Not a path for these tools | The MCP Hub is "a catalog of MCP servers", backed by the GitHub MCP Registry. The Skill Hub is "a catalog of skills" (a `SKILL.md` folder), backed by ClawHub (6, 7). Neither distributes Python tools. Getting `diffbot-mcp` into the GitHub MCP Registry would be a separate `diffbot-mcp` task, outward and gated. It isn't part of this plan. | +| **4. Examples / docs contribution** | Later, optional, gated | CONTRIBUTING routes "complete, production-style applications" to `agentscope-samples`, and keeps `examples/` in core for framework-feature demos. The 2.x docs have no integrations or partners page. A Diffbot research-agent sample in `agentscope-samples` using `agentscope-diffbot`, opened after an issue, is the realistic first public step **after** 0.1.0 ships. Andrew's explicit go is required. | +| **5. `agentscope-runtime` adapter tools** | ❌ No | Alibaba first-party ModelStudio components. No documented third-party intake process exists. | + +**Where code lives before the repo exists:** nowhere public. The M1 spike runs in a local scratch directory. No integration code goes into `diffbot-python`: its `release.yml` tags `v*` for the SDK, and mixing packages would complicate releases. + +--- + +## 6. Phased milestones + +| # | Milestone | Who | Exit criteria | +| --- | --- | --- | --- | +| **M0** | Decisions: distribution path (Q1), name/repo/author/licence (Q2), confirm the v0.1 7-tool scope, auth fallback (Q3), KG Query default (Q4), permission default (Q5), upstream authorization (Q8). | πŸ…° | Answers recorded in this doc. | +| **M1** | **Local spike** (no repo, no publish). Build `diffbot_web_search` and `diffbot_extract` as `ToolBase` subclasses on `agentscope` 2.0.12 (and 2.0.3), Python 3.11. Run them inside an `Agent` in DEFAULT permission mode. Confirm: no confirmation prompt; `ToolChunk` and metadata render in the console; shared-client lifecycle; whether streaming Ask chunks are useful; and a test or mock model for CI. | πŸ›  locally | Findings appended to the research notes; Β§4 amended if needed. | +| **M2** | **Repo + scaffold.** Create `diffbot/agentscope-diffbot`, enable Actions, add a PyPI trusted publisher (a pending publisher for the new project name), branch protection, and Dependabot per policy. | πŸ…° creates repo + PyPI publisher; πŸ›  scaffolds via PR | `tests.yml` green on an empty package. | +| **M3** | **v0.1 tools.** All 7 tools, DQL builders + injection tests, `DiffbotTools` factory + `ToolGroup` helper, README with an example agent. | πŸ›  PRs; πŸ…° reviews and merges (no bot merges) | Unit + agent-smoke CI green on the matrix; manual live run recorded. | +| **M4** | **Release 0.1.0** (stable, no RC). Tag β†’ trusted publishing β†’ GitHub release. | πŸ…° go to tag; πŸ›  tags | `pip install agentscope-diffbot` works in a clean venv with `agentscope` 2.x. | +| **M5** | SDK README link to the new package (separate PR in `diffbot-python`). | πŸ›  drafts; πŸ…° merges | Linked. | +| **M6** | *(Optional, gated)* Upstream visibility: an issue on `agentscope-ai/agentscope-samples` (or `agentscope-ai/agentscope`) proposing a Diffbot research-agent sample, then the PR if maintainers agree. | πŸ…° **explicit go required** before any post; πŸ›  drafts | Maintainers' decision. | +| β€” | DQL field names disagree with the n8n source or the ontology | πŸ…Ή only if triggered | Confirmed field list. | + +--- + +## 7. Open questions for Andrew + +1. **Primary distribution path:** approve a Diffbot-owned PyPI package (Β§5.4, option 1), with no core PR and the hubs out of scope? +2. **Name, repo, author, licence:** `agentscope-diffbot` (import `agentscope_diffbot`), repo `diffbot/agentscope-diffbot` (πŸ…° creates), author `Diffbot `, MIT? The alternative name is `diffbot-agentscope`. +3. **Auth fallback:** should the token be strictly explicit (recommended), or may `DiffbotTools()` fall back to reading the `DIFFBOT_API_TOKEN` env var (never `~/.diffbot/credentials`)? +4. **KG Query in the default tool list:** exclude it by default (recommended, since models write poor DQL) with an `include_kg_query=True` opt-in, or include it? +5. **Permission default:** auto-allow all 7 tools (read-only, `ALLOW`; recommended, matching AgentScope's own `WebSearch` example), or return PASSTHROUGH so that DEFAULT mode asks the user before spending Diffbot credits? +6. **Streaming Ask:** keep v0.1 as one `ToolChunk`, or stream the answer incrementally (AgentScope supports it)? This is decided after the M1 spike. +7. **Attribution:** a distinct User-Agent (for example `agentscope-diffbot/0.1 diffbot-python/3.4`)? It would be a separate small SDK option and doesn't block v0.1. +8. **Upstream authorization:** once this plan is accepted, is an issue or PR on `agentscope-ai/agentscope-samples` (or core) authorized? This needs explicit go and happens no earlier than M6. +9. **Other public paths:** do you want `diffbot-mcp` checked or listed in the GitHub MCP Registry, so that AgentScope's `GitHubMCPHub` can install it? This is a separate task for `diffbot-mcp`, outward, and gated. +10. **Minimum AgentScope version:** `>=2.0.3` (the first release with `ToolBase.call`), or simply the latest 2.0.x at implementation time? + +--- + +## 8. Recommended first milestone + +**M0 + M1.** Andrew answers Q1–Q5 and Q8. The implementer runs the local spike: `diffbot_web_search` and `diffbot_extract` as `ToolBase` subclasses backed by `DiffbotAsync` from the released `diffbot` 3.4.x, inside an AgentScope 2.0.12 `Agent` in DEFAULT permission mode. The spike confirms no confirmation prompt, readable `ToolChunk` output, a safe client lifecycle, and a CI-friendly way to drive an agent without a real LLM. Findings go into the research notes and Β§4. This needs no new repo, no SDK change, and no outward post. Meanwhile πŸ…° creates `diffbot/agentscope-diffbot` and the PyPI pending publisher so M2 can start as soon as the spike lands. + +--- + +## 9. Outward-facing steps (each is a gate; none is done by this PR) + +Each item below needs **Andrew's explicit go** at the milestone listed. This plan's PR does none of them. + +| Step | Milestone | Notes | +| --- | --- | --- | +| Create the public repo `diffbot/agentscope-diffbot` | M2 | πŸ…° (or πŸ…Ή if org-owner rights are needed). | +| Register the PyPI pending trusted publisher for `agentscope-diffbot` | M2 | This reserves the project name on publish. | +| Publish `agentscope-diffbot` 0.1.0 to PyPI and create the GitHub release | M4 | Stable, no RC. | +| Link the package from the `diffbot-python` README | M5 | Separate PR, merged by Andrew. | +| Open an issue on `agentscope-ai/agentscope-samples` or `agentscope-ai/agentscope` proposing a sample | M6 | Issue before PR, per CONTRIBUTING. | +| Open a sample PR on `agentscope-ai/agentscope-samples` | M6 | Only after the maintainers respond. | +| Open a docs PR on `agentscope-ai/docs` | M6+ | Only if maintainers ask; the 2.x docs have no integrations page today. | +| Open a core PR adding Diffbot tools to `agentscope.tool` | not recommended | Listed for completeness. | +| Post in AgentScope Discussions, Discord, or DingTalk; star the repo; any other announcement | any | Each needs a go. | +| List `diffbot-mcp` in the GitHub MCP Registry / AgentScope MCP Hub | separate `diffbot-mcp` task | Out of scope here (Q9). | diff --git a/docs/plans/agentscope-research-notes.md b/docs/plans/agentscope-research-notes.md new file mode 100644 index 0000000..8d2e428 --- /dev/null +++ b/docs/plans/agentscope-research-notes.md @@ -0,0 +1,78 @@ +# AgentScope integration: research notes + +> Companion to [agentscope-integration.md](./agentscope-integration.md). Collected 2026-12-03. These are raw findings, citations, and things that didn't belong in the plan. "βœ…" means the page or file was fetched during this run (via WebFetch, `gh api` read-only, or the PyPI JSON API). Quotes are verbatim from the fetched content; paraphrases are not quoted. + +## 1. Pages and files opened + +| Source | URL | Status | Key findings | +| --- | --- | --- | --- | +| Legacy tool tutorial | https://doc.agentscope.io/tutorial/task_tool.html | βœ… (version selector shows "Stable(v1.0)" and "v0.1.x") | v1 API: tool functions return `ToolResponse`; `toolkit.register_tool_function(my_search, preset_kwargs={"api_key": "xxx"})`; `create_tool_group`, `update_tool_groups(group_names=[...], active=True)`, `reset_equipped_tools`. Built-ins listed: `execute_python_code`, `execute_shell_command`, `view_text_file`, `write_text_file`, `insert_text_file`, DashScope/OpenAI multimodal tools. No web search tool. **Not the current API.** | +| Docs root | https://docs.agentscope.io/ | βœ… (HTTP 308 redirect to the versioned site) | PyPI's `Documentation` URL for `agentscope`. Sourced from https://github.com/agentscope-ai/docs (`en/versions//…mdx`; versions 1.0.21 and 2.0.10 through 2.0.13dev are present). | +| Tool overview 2.0.12 | `agentscope-ai/docs` `en/versions/2.0.12/building-blocks/tool/overview.mdx` | βœ… | Concepts table: Tool (`ToolBase`, `FunctionTool`, `MCPTool`), Toolkit, Tool Group. `Toolkit(tools=[Bash(), Read(), Write(), Edit()])`; "A `Toolkit` created with `tools` alone exposes those tools in the special `"basic"` group, which is always active." | +| Python Tool 2.0.12 | https://docs.agentscope.io/en/versions/2.0.12/building-blocks/tool/python-tool | βœ… (live page and docs-repo source) | `ToolBase` attribute and method tables. The custom-tool example is `class WebSearch(ToolBase)` with `is_read_only = True` and `check_permissions` returning `PermissionDecision(behavior=PermissionBehavior.ALLOW, message="Web search is read-only.")`, and `call` returning `ToolChunk(content=[TextBlock(text=results)])`. `FunctionTool` args: `func, name, description, input_schema (dict or BaseModel), is_concurrency_safe=True, is_read_only=False, is_state_injected=False`. Note: "Wrapped functions default to `ASK` permission behavior: the user must explicitly allow each call. Subclass `ToolBase` directly when you need custom permission logic." Tool middleware (`ToolMiddlewareBase.on_tool_call`), onion order. | +| Meta Tool 2.0.12 | `…/building-blocks/tool/manage-tools.mdx` | βœ… | `ToolGroup(name, description, instructions, tools=[…])`; `reset_tools` auto-registered when non-basic groups exist; "The meta tool input represents the **final state** of all groups". | +| MCP 2.0.12 | `…/building-blocks/tool/mcp.mdx` | βœ… (first ~80 lines) | `MCPClient(name, is_stateful, mcp_config=StdioMCPConfig(...) / HttpMCPConfig(url, headers={"Authorization": "Bearer xxx"}))`; `Toolkit(mcps=[client])`; tools are named `mcp__{server_name}__{tool_name}`; "tools annotated with `readOnlyHint` are recognized as read-only by the permission system (auto-allowed in EXPLORE and ACCEPT_EDITS modes; in DEFAULT they still ASK unless an allow rule matches)". "AgentScope 2.0.11 uses the MCP Python SDK 2.x (`mcp>=2.0.0`)." `enable_tools` / `disable_tools` filters. | +| MCP Hub 2.0.12 | `…/deploy/hub/mcp-hub.mdx` | βœ… (first ~90 lines) | "An MCP hub is a catalog of MCP servers your users browse and install from inside the app." Ships `GitHubMCPHub` (base_url `https://api.mcp.github.com`). A feature of Agent Service (`create_app(mcp_hubs=[...])`). Credentials are entered once at install time. **For MCP servers only.** | +| Skill Hub 2.0.12 | `…/deploy/hub/skill-hub.mdx` | βœ… (first ~90 lines) | "A skill hub is a catalog of skills … A skill is a folder, a `SKILL.md` …". Ships `ClawSkillHub` (`https://clawhub.ai`). `create_app(skill_hubs=[...])`. **For skills only.** | +| 2.0.12 docs tree | `agentscope-ai/docs` `en/versions/2.0.12/` | βœ… | No "integrations", "partners", or "ecosystem" page. Sections: building-blocks, deploy (agent-service, channel, hub, rag, sharing, sop, workspace-manager), quickstart, release notes, FAQ. | +| Repo metadata | https://github.com/agentscope-ai/agentscope | βœ… | `gh api repos/modelscope/agentscope` returns `agentscope-ai/agentscope` (redirect). Default branch `main`, ~37k stars, pushed 2026-12-03. Branches include `main`, `v0`, `v1`. Releases: v2.0.12 (2026-11-16), v2.0.11 (2026-10-27), v2.0.10 (2026-10-12). `_version.py` on main: `2.0.13dev`. | +| `pyproject.toml` | …/blob/main/pyproject.toml | βœ… (top 60 lines + grep) | `name = "agentscope"`, licence `Apache-2.0`, `requires-python = ">=3.11"`, deps include `httpx`, `mcp>=2.0.0`, `pydantic`. No `entry-points` section. | +| `src/agentscope/tool/__init__.py` | …/tree/main/src/agentscope/tool | βœ… | Exports `ToolBase, ParamsBase, ToolMiddlewareBase, MCPTool, FunctionTool, ToolGroup, Toolkit, ToolChunk, ToolResponse, RegisteredTool`, plus built-ins `AskUser, ResetTools, Bash, PowerShell, Edit, Glob, Grep, Read, Write, Task*`, and backends. | +| `tool/_base.py` | same | βœ… | `ToolBase` attributes as documented; `async def call(...)`: "This is the new override point for tool implementations. Subclasses should override this method instead of `__call__`." `__call__` runs middlewares. `check_permissions` is abstract. `check_read_only` defaults to `self.is_read_only`. `ParamsBase(BaseModel)` strips `title` from the JSON schema. | +| `tool/_toolkit.py` | same | βœ… | `Toolkit.__init__(tools, skills_or_loaders, mcps, tool_groups, meta_tool_response_template, skill_instruction_template)`; `"basic"` reserved; `async add_tool(tool, group_name="basic")` logs "Duplicate tool name '%s' found in group '%s', overwriting it."; `async get_tool_schemas(groups=None)`; `async call_tool(tool_call, state)` docstring: "the tool functions only need to return/yield the ToolChunk objects in an incremental manner." | +| `tool/_adapters.py` | same | βœ… | `FunctionTool.check_permissions` returns `ASK` with "Custom function tools must be explicitly allowed by the user." unless a `permission` was passed. `MCPTool` sets `is_read_only` from the MCP `readOnlyHint` annotation. | +| `tool/_response.py` | same | βœ… | `ToolChunk(content: List[TextBlock\|DataBlock], state=RUNNING, is_last=True, metadata: dict, id)`. `ToolResponse` has accumulated content and a final state (`ERROR`, `DENIED`, `INTERRUPTED`, `SUCCESS`). | +| `tool/_types.py` | same | βœ… (grep) | The only remaining `preset_kwargs` mention is in a docstring ("Remove preset_kwargs from the JSON schema"). GitHub code search for `preset_kwargs` in the repo finds only this file. | +| `tool/_tool_group.py` | same | βœ… | `ToolGroup(name, description=None, instructions=None, tools=None, skills_or_loaders=None, mcps=None)`; a description is required unless the name is `"basic"`. | +| `permission/_types.py` | …/tree/main/src/agentscope/permission | βœ… | `PermissionMode`: DEFAULT, ACCEPT_EDITS, EXPLORE, BYPASS, DONT_ASK. The DEFAULT row says "Every operation asks for permission unless: an allow rule matches, OR the tool's `check_permissions` explicitly returns ALLOW". | +| `permission/_engine.py` | same | βœ… | DEFAULT order: deny rules β†’ ask rules β†’ **read-only fast path β†’ ALLOW** β†’ tool `check_permissions` β†’ allow rules β†’ ASK. `_check_read_only_fast_path` docstring: "A read-only invocation has no side effects, so it is auto-allowed in every `PermissionMode`." Present at v2.0.8 and v2.0.10; **absent at v2.0.3**. | +| `credential/_base.py`, `_openai.py` | …/tree/main/src/agentscope/credential | βœ… | `CredentialBase(BaseModel)` with `id` and `name`; classmethods `get_chat_model_class()` etc. raise `NotImplementedError`. `OpenAICredential(api_key: SecretStr, organization, base_url)`. Model-oriented; no tool credentials. | +| `agent/_agent.py` | …/blob/main/src/agentscope/agent/_agent.py | βœ… (`__init__`) | `Agent(name, system_prompt, model, toolkit=None, middlewares=None, state=None, offloader=None, model_config=None, context_config=None, react_config=None, injection_config=None)`; toolkit is "the sole source" of tools, MCPs, and skills. | +| `_base.py` at tags | `?ref=v2.0.0 … v2.0.8` | βœ… | `async def call(` count: v2.0.0 0, v2.0.1 0, v2.0.2 0, **v2.0.3 1**, v2.0.5 1, v2.0.8 1. | +| `CONTRIBUTING.md` | …/blob/main/CONTRIBUTING.md | βœ… (426 lines) | Claim or create an issue first; max 5 open issues per contributor; PR against `main`; Conventional Commits; companion docs PR in `agentscope-ai/docs`. "Open an issue before non-trivial work." "Don't add dependencies casually." Lazy-import principle. Module guides exist only for Chat Model (credential + model + model-card YAML + two formatters), Agent, Workspace, and Examples. **No guide for tools.** "For other modules, please open an issue first so we can coordinate." Examples: `examples/` for feature demos; "For more complete, production-style applications, please contribute them to agentscope-samples". There is also an "AI-assisted contributions" section. | +| PR #2931 | https://github.com/agentscope-ai/agentscope/pull/2931 | βœ… | "feat(tool): add WebSearch and Python builtin tools", opened 2026-09-28, still **open**, not merged. The only comment is from the `github-actions` PR-guard bot: "This pull request does not close an issue. Please open one…". | +| Issue search | `repo:agentscope-ai/agentscope tavily OR exa OR firecrawl OR serpapi OR brave` | βœ… | Only DeepResearch example fixes (Tavily naming) and hub fixes. No vendor-tool intake issues. | +| `agentscope-samples` | https://github.com/agentscope-ai/agentscope-samples | βœ… (tree + `deep_research/agent_deep_research/main.py`) | Tavily via MCP: `StdIOStatefulClient(name="tavily_mcp", … args=["-y", "tavily-mcp@latest"], env={"TAVILY_API_KEY": os.getenv("TAVILY_API_KEY", "")})`. Pushed 2026-11-11. Note: this uses the 1.x-style `StdIOStatefulClient`; 2.x uses `MCPClient(...)`. | +| `agentscope-runtime` | https://github.com/agentscope-ai/agentscope-runtime | βœ… (tree) | `src/agentscope_runtime/adapters/agentscope/tool/{tool.py,sandbox_tool.py}`, cookbook `tools/modelstudio_search.md`. PyPI `agentscope-runtime` 1.1.6.post2. Last pushed 2026-06-04. | +| Runtime tools page (search result only) | https://runtime.agentscope.io/en/tools/tools.html | ⚠️ search snippet | Says ModelstudioSearch / ModelstudioSearchLite connect to AgentScope via `agentscope_tool_adapter`. Not opened directly. | +| `agentscope-bricks` | https://github.com/agentscope-ai/agentscope-bricks | βœ… | **Archived**, last pushed 2026-01-19. PyPI `agentscope-bricks` 0.1.2, author "Modelstudio Team". | +| `agentscope-datacircle` | https://github.com/waynehamadi/agentscope-datacircle Β· PyPI JSON | βœ… | PyPI 0.1.0 (no author metadata). hatchling, MIT, `requires-python >=3.10`, `dependencies = ["agentscope>=1.0.0"]`. `__init__` picks v1 or v2 code by the installed major version. v2: `DatacircleTool(ToolBase)` with `is_read_only = True`, `check_permissions` β†’ `ALLOW`, `call` β†’ `ToolChunk`, `ToolResultState.ERROR` on refusal. A `tools()` factory is used as `Toolkit(tools=agentscope_datacircle.tools())`. Shim comment: "AgentScope 2.0.0 calls a tool's __call__, later ones its call". | +| GitHub repo search | `agentscope tool in:name,description -org:agentscope-ai -org:modelscope` | βœ… | Mostly apps and dashboards. `agentscope-datacircle` is the only vendor-tool package. | +| PyPI JSON | `https://pypi.org/pypi//json` | βœ… | `agentscope` 2.0.12 (2026-11-16), `requires_python >=3.11`; 1.x last = 1.0.21 (2026-05-25); 2.0.0 = 2026-05-25. **404 (unclaimed):** `agentscope-diffbot`, `diffbot-agentscope`, `agentscope-{tavily,exa,firecrawl,serpapi,brightdata,jina,apify,composio,mem0,browserbase,e2b,studio,scrapegraph,oxylabs,zep,perplexity,bing,tools,tool,plugin,extensions,contrib,langchain}`, `{tavily,exa,firecrawl,brightdata,apify,composio,scrapegraph}-agentscope`. | +| Official MCP Registry | https://registry.modelcontextprotocol.io/v0/servers?search=diffbot | βœ… | `io.github.diffbot/diffbot-mcp` v0.2.1, "Web search, page extraction, crawling, and Knowledge Graph queries from Diffbot's web index."; PyPI stdio package `diffbot-mcp`; remote `streamable-http` `https://mcp.diffbot.com/mcp` with an optional `Authorization: Bearer {diffbot_token}` header. | +| GitHub MCP Registry | https://api.mcp.github.com/v0/servers?search=diffbot | ⚠️ inconclusive | The `search` parameter didn't filter (it returned the generic top 30 of 1,142). Whether `diffbot-mcp` is listed there is **unverified**. | +| Web search | "AgentScope integration third-party tool package…" | βœ… | Surfaced PR #2931, the runtime tools page, and Java PRs #4103 (built-in web tools opt-in) and #3242 (Parallel search). No vendor PyPI packages for Python AgentScope. | + +## 2. Diffbot SDK facts (this checkout, `diffbot` 3.4.1) + +- `pyproject.toml`: `version = "3.4.1"`, `requires-python = ">=3.9"`. LICENSE: MIT, "Copyright (c) 2023 Diffbot". +- `DiffbotAsync.__init__(self, token: str, …)`: `if not token: raise ValidationError("token is required")`. It does **not** call `resolve_token()`; the docstring example passes `token=os.getenv("DIFFBOT_API_TOKEN")`. +- `DiffbotAsync` methods: `close`, `request`, `extract` (default `api="analyze"`, `fmt="markdown"`), `ask(messages, *, response_format)` (async iterator of text), `ask_json(messages, schema, *, response_format)`, `crawl*`, `dql` (overloads), `dql_parallel`, ontology helpers, `web_search`, `account`, `verify_token`, `entities`, `nlp`. +- `grep -rni enhance src/diffbot` finds only `types.py:35` "DQL / Enhance-bulk export formats". **No Enhance wrapper**, which doesn't matter because Enhance is deferred. +- `resolve_token()` (`_auth.py`): explicit β†’ `DIFFBOT_API_TOKEN` β†’ `~/.diffbot/credentials`. Not used by the integration. +- User-Agent is hard-coded as `diffbot-python/` (`client.py` lines 166 and 547). + +## 3. Discrepancies against the task's starting notes + +- The starting URL `doc.agentscope.io/tutorial/task_tool.html` serves the **v1.0** docs. The current 2.x docs are at `docs.agentscope.io`. +- The starting notes refer to `modelscope/agentscope`. The official repo is now `agentscope-ai/agentscope` (redirect). +- "Toolkit / ToolBase": confirmed for 2.x. `register_tool_function` is the v1 API. +- "MCP Hub, Skill Hub": both exist, but only in Agent Service, and only for MCP servers and `SKILL.md` skills respectively. Neither is a Python-tool gallery. + +## 4. Things not verified (carry into the M1 spike) + +- Whether `check_permissions β†’ ALLOW` and `is_read_only=True` produce no prompt in DEFAULT mode on **every** 2.0.x from 2.0.3. The read-only fast path is absent at v2.0.3; `ALLOW` from `check_permissions` should cover that case, but it hasn't been run. +- Whether a shared, lazily created `DiffbotAsync` is safe across Agent Service requests (event-loop affinity of `httpx.AsyncClient`). +- Whether AgentScope ships a scripted or mock chat model for tests. +- How `ToolChunk.metadata` and long `TextBlock`s render in the console and web UI, and how the agent `offloader` treats large tool results. +- Whether streaming `ToolChunk`s (for Ask) render incrementally in the console and web UI. +- Whether `agentscope-runtime` adapters are compatible with `agentscope` 2.x. Not needed for the plan. +- Whether `diffbot-mcp` is in the GitHub MCP Registry (and so installable via `GitHubMCPHub`). +- Any policy on third-party use of the `agentscope-` PyPI prefix. None was found; the absence of a policy is not proof that the prefix is unrestricted. + +## 5. Decisions log + +| Date | Decision | Source / evidence | +| --- | --- | --- | +| 2026-12-02 | Org/Person Enhance deferred from v0.1 across integrations; ship 7 read-only operations. | Andrew, recorded in the Langflow plan. Reason: matches Jerome's 2026-11-17 view that Enhance is "bloat for the LLM" and Dify's scope; no SDK change needed. | +| 2026-12-03 | *(Proposed, pending Andrew)* Package `agentscope-diffbot`, Diffbot-owned, PyPI, stable 0.1.0 without RCs. | Β§5.3–§5.4 and Β§4.12 of the plan. | diff --git a/docs/plans/dependabot-audit-notes.md b/docs/plans/dependabot-audit-notes.md new file mode 100644 index 0000000..cfbbe24 --- /dev/null +++ b/docs/plans/dependabot-audit-notes.md @@ -0,0 +1,118 @@ +# Dependabot audit: raw evidence + +> Companion to [dependabot-audit.md](./dependabot-audit.md). Collected 2026-12-03 with read-only `gh` (token scope: maintain/push on `diffbot-python`, not admin). The `gh` invocations below are the exact ones used; outputs are trimmed. No secrets appear here; job-definition JSON from logs is omitted. + +## 1. Config presence and history + +```sh +gh api repos/diffbot//contents/.github/dependabot.yml --jq .content | base64 -d +gh api "repos/diffbot//commits?path=.github/dependabot.yml" +``` + +| Repo | Commit | Date (UTC) | Message | +| --- | --- | --- | --- | +| ai-sdk | da4d727 | 2026-11-28 05:48 | Add Dependabot config for Diffbot packages and GitHub Actions | +| langchain-diffbot-typescript | 448dcff | 2026-11-28 05:48 | same | +| diffbot-pi | 7dfa7b7 | 2026-11-28 05:48 | same | +| langchain-diffbot | 43404cb | 2026-11-28 05:48 | same | +| diffbot-mcp | bb779ef | 2026-11-28 05:48 | same | +| dify-diffbot | 9bd3fe4 | 2026-11-28 05:48 | same | +| diffbot-skills | b700179 | 2026-11-28 05:48 | Add Dependabot config for GitHub Actions | +| diffbot-typescript | 62a78ca | 2026-11-28 05:48 | same | +| diffbot-python | d12c72e | 2026-11-28 05:48 | same | + +All files have the same header comment ("Diffbot-owned packages and GitHub Actions only, kept low-noise. Floor rule: …"). Each package ecosystem is `weekly`/`monday`, has `open-pull-requests-limit: 5`, `versioning-strategy: increase-if-necessary`, an `allow` list (`@diffbot/*` or `diffbot`), and a `diffbot` group. `github-actions` is `monthly`, has `open-pull-requests-limit: 2`, and a `github-actions` group `"*"`. `langchain-diffbot-typescript` uses `directories:` (4 entries) with `group-by: dependency-name` inside the `diffbot` group. Directories: `dify-diffbot` pip uses `/diffbot`. Comments in `diffbot-mcp` and `dify-diffbot` already note the deploy-on-merge and two-file exact-pin cautions. + +## 2. Dependabot runs (dynamic workflow) + +```sh +gh api repos/diffbot//actions/workflows --jq '.workflows[] | select(.path|test("dependabot"))' +gh api "repos/diffbot//actions/workflows//runs?per_page=20" +``` + +(`gh run list --workflow dependabot-updates` does not find the dynamic workflow by name, so use the workflow id.) + +| Repo | Workflow id | Total runs | Runs (UTC, conclusion) | +| --- | --- | --- | --- | +| ai-sdk | 433456745 | 6 | 11-28 Γ—4 βœ… (npm Γ—2, actions Γ—2) Β· npm 11-30 14:23 βœ… Β· actions 12-01 14:51 βœ… | +| langchain-diffbot-typescript | 433456631 | 6 | 11-28 Γ—4 βœ… Β· npm "in /., /examples/company-research, /examples/dql-explorer, /fixtures/worker" 11-30 13:56 βœ… Β· actions 12-01 βœ… | +| diffbot-pi | 433456757 | 6 | 11-28 Γ—4 βœ… Β· npm 11-30 05:55 βœ… Β· actions 12-01 05:45 βœ… | +| langchain-diffbot | 433456714 | 6 | **uv 11-28 06:01 ❌ Γ—2** Β· actions 11-28 Γ—2 βœ… Β· **uv 11-30 18:47 βœ…** Β· actions 12-01 19:11 βœ… | +| diffbot-mcp | 433456782 | 7 | pip 11-28 Γ—2 βœ… Β· actions 11-28 Γ—2 βœ… Β· pip 11-30 βœ… Β· actions 12-01 Γ—2 βœ… (one is a PR refresh "for actions/checkout, burnett01/rsync-deployments, sigstore/cosign-installer, astral-sh/setup-uv, actions/setup-python") | +| dify-diffbot | 433456679 | 6 | pip `/diffbot` 11-28 Γ—2 βœ… Β· actions 11-28 Γ—2 βœ… Β· pip 11-30 βœ… Β· actions 12-01 βœ… | +| diffbot-skills | 433456663 | 3 | actions 11-28 Γ—2 βœ… Β· 12-01 βœ… | +| diffbot-typescript | 433456684 | 3 | actions 11-28 Γ—2 βœ… Β· 12-01 βœ… | +| diffbot-python | 283747365 (+ 283746242 "Dependency Graph") | 18 | actions 11-28 βœ…, 12-01 βœ…. Before: pip `requests` 2026-05-26 ❌; uv `pytest` / `anyio` 2026-06-12 β†’ 10-26 ❌ Γ—13; uv `certifi` 2026-10-26 04:03 βœ… (opened PR #9) | + +2026-11-30 is a Monday (weekly schedule), and 2026-12-01 is the first monthly slot. + +### 2.1 `langchain-diffbot` uv failure (run 46114724232) + +```sh +gh run view 46114724232 --repo diffbot/langchain-diffbot --log-failed +``` + +``` +ERROR Error during file fetching; aborting: The following path based dependencies could not be retrieved: "langchain-core" at /pyproject.toml, "langchain-tests" at /pyproject.toml +| path_dependencies_not_reachable | "\"langchain-core\" at /pyproject.toml", ... +##[error]Dependabot encountered an error performing the update +``` + +Fix commit: `930ef78` 2026-11-29 23:17 "Remove the [tool.uv.sources] table so Dependabot can run (#8)". Current `pyproject.toml` has no `[tool.uv.sources]` and keeps `diffbot>=3.4.0,<4`, `langchain-core>=1.0,<2.0`, and dev `langchain-tests>=1.0,<2.0`. + +### 2.2 `diffbot-python` old uv failures (run 40274317551, 40299670596) + +These are security-update jobs (`"command":"security"` in the job definition), not version updates: + +``` +Handled error whilst updating pytest: dependency_file_not_resolvable +error: No solution found when resolving dependencies for split (markers: python_full_version == '3.9.*') +cause: Because the requested Python version (>=3.9) does not satisfy Python>=3.10 and pytest==9.0.3 depends on Python>=3.10 ... +``` + +`anyio` failed the same way. + +## 3. Dependabot PRs and branches + +```sh +gh pr list --repo diffbot/ --author app/dependabot --state all --limit 20 +gh api repos/diffbot//branches --paginate --jq '.[].name | select(startswith("dependabot"))' +``` + +| Repo | PRs | `dependabot/*` branches | +| --- | --- | --- | +| ai-sdk | #7 MERGED (actions, 3 updates) | β€” | +| langchain-diffbot-typescript | #9 MERGED (actions, 5) | β€” | +| diffbot-pi | #6 MERGED (actions, 2) | β€” | +| langchain-diffbot | **#9 OPEN** 2026-11-30 "bump diffbot from 3.4.0 to 3.4.1 in the diffbot group" (files: `uv.lock` only; checks lint+typing, unit py3.10, py3.13 βœ…; MERGEABLE) Β· #7 MERGED (actions, 4) | `dependabot/uv/diffbot-e8b783c7d2` | +| diffbot-mcp | **#11 OPEN** 2026-11-28 "Bump the github-actions group with 5 updates" (files: `.github/workflows/{main,mcpb,publish-mcp-registry,release,tests}.yml`; checks validate, pytest 3.10/3.12, check βœ…, release skipped; MERGEABLE; updated 12-01) | `dependabot/github_actions/github-actions-b1d8d6e90e` | +| dify-diffbot | #7 MERGED (actions, 4) | β€” | +| diffbot-skills | #4 MERGED (actions, 3) | β€” | +| diffbot-typescript | #11 MERGED (actions, 3) | β€” | +| diffbot-python | #17 MERGED (actions, 4) Β· #9 CLOSED 2026-10-26 (certifi 2026.5.20 β†’ 2026.10.19, uv) Β· #7 CLOSED 2019-11-04 (requests, pip) | **`dependabot/uv/certifi-2026.10.19`** (stale) | + +`diffbot-mcp` `.github/workflows/main.yml` has `on: push: branches: [main]` with a `deploy` job. `mcpb.yml`, `tests.yml`, and `version-check.yml` also run on push to `main`. + +## 4. Why "no PR" is correct for most package jobs + +| Package | Latest (2026-12-03) | Repo ranges | +| --- | --- | --- | +| `diffbot` (PyPI) | 3.4.1 | langchain-diffbot `>=3.4.0,<4` (lock was 3.4.0 β†’ PR #9) Β· diffbot-mcp `>=3.4.1,<4` Β· dify-diffbot `==3.4.1` (requirements.txt line 2, pyproject.toml line 9) Β· diffbot-skills Markdown `'diffbot>=3.4.0,<4'` | +| `@diffbot/typescript` (npm) | 0.6.0 (`latest` and `next`) | ai-sdk, diffbot-pi, langchain-diffbot-typescript (root peer + dev, fixtures/worker, both examples): all `^0.6.0` | + +## 5. Security side and access limits + +```sh +gh api "repos/diffbot//dependabot/alerts?state=open" --jq length +gh api repos/diffbot/ --jq .security_and_analysis +``` + +- Alerts: 8 repos returned `0`. `diffbot-python` returned `403 "Dependabot alerts are disabled for this repository."` +- `security_and_analysis`: `langchain-diffbot-typescript` and `diffbot-typescript` show `dependabot_security_updates: disabled` (secret scanning disabled too). The other 7 return `null` (needs admin). +- Token: `permissions` on `diffbot-python` = maintain/push/triage/pull, not admin. `orgs/diffbot/repos` shows 67 repos, 0 private. +- `repos/diffbot/diffbot-dev-docs` β†’ 404 (local-only repo; not read). +- No browser, so the Insights β†’ Dependency graph β†’ Dependabot UI was not opened. The Actions-run API above shows the same jobs. + +## 6. Other org repos (not in scope) + +Active since 2026-09 and without `dependabot.yml`: `codegpt-pi` ("CodeGPT provider for Pi"), `code-gpt-docs` ("Docusaurus page"). `diffbot-openclaw` was deliberately not inspected (standing policy). diff --git a/docs/plans/dependabot-audit.md b/docs/plans/dependabot-audit.md new file mode 100644 index 0000000..cc69daf --- /dev/null +++ b/docs/plans/dependabot-audit.md @@ -0,0 +1,140 @@ +# Dependabot audit across Diffbot library repos: plan and findings + +> **Status:** plan only, plus read-only findings as of **2026-12-03**. **Audience:** the implementer (πŸ› ) and Andrew (πŸ…°). +> This PR changes no `.github/dependabot.yml`, opens no fix PRs, merges nothing, and sets up no monitoring. Every fix below is a later milestone that needs Andrew's go. +> Raw commands and trimmed outputs: [dependabot-audit-notes.md](./dependabot-audit-notes.md). + +Legend: πŸ…° Andrew must act or approve Β· πŸ›  implementer + +--- + +## 0. TL;DR + +- **Healthy.** All 9 in-scope repos have `.github/dependabot.yml` on `main`. Each file was added in one commit at 2026-11-28 05:48 UTC (the 2026-11-27 approval), and all 9 match the intended shape: weekly Monday package updates allow-listed to Diffbot packages, `increase-if-necessary`, limit 5, a `diffbot` group, and monthly grouped `github-actions` with limit 2. The latest Dependabot run in every repo **succeeded**: npm, pip, uv, and the 2026-12-01 monthly actions run. +- **The `langchain-diffbot` uv job was broken and is now fixed.** Its first two uv runs (2026-11-28) failed with `path_dependencies_not_reachable` for `langchain-core` and `langchain-tests`, the predicted `[tool.uv.sources]` problem. PR #8 (`930ef78`, 2026-11-29) removed that table. The next uv run (2026-11-30) succeeded and opened **PR #9** (`diffbot` 3.4.0 β†’ 3.4.1, `uv.lock` only, floor unchanged, CI green). **No pip fallback is needed.** +- **Two Dependabot PRs are open and waiting on Andrew.** `langchain-diffbot#9` (uv lock bump) and `diffbot-mcp#11` (actions group, 5 updates). **Caution:** `diffbot-mcp#11` edits `.github/workflows/main.yml`, and any push to `main` there deploys `mcp.diffbot.com`. Merging it is a deploy. +- **Leftover in `diffbot-python`.** Branch `dependabot/uv/certifi-2026.10.19` still exists, although its PR #9 was closed on 2026-10-26. It came from **security-update** jobs that ran before the actions-only config. Most of those uv jobs failed (`dependency_file_not_resolvable`: `requires-python >=3.9` vs pytest 9.0.3 / anyio needing 3.10). The Dependabot alerts API now says alerts are **disabled** for this repo, and no uv job has run since 2026-10-26. Deleting the branch is a later, Andrew-approved cleanup. +- **Unverified (still to watch):** + - `dify-diffbot`'s exact pin. It will only be exercised on the next SDK release: does one PR change both `requirements.txt` and `pyproject.toml`? + - `langchain-diffbot-typescript`'s `group-by: dependency-name` across 4 directories. Runs succeed, but there has been no `@diffbot/typescript` release since the config landed, so no PR yet. + - Security-update and alert settings for 7 of 9 repos. These need admin access; the token can't read them. +- **Fixes that should follow (all later, all gated):** delete the stale `diffbot-python` branch; add a note to the `langchain-diffbot` repo docs that `[tool.uv.sources]` must stay out; decide the security-updates and alerts policy; a one-off check after the next SDK release. **No config edits are needed today.** +- **For Andrew:** merge or close the two open PRs when convenient (no watcher, per policy). Answer the questions in Β§6. + +--- + +## 1. Method + +The method is the same for each repo. Steps marked *UI* need a browser and maintainer/admin access. Every other step uses read-only `gh`. + +| Step | How | What "pass" looks like | +| --- | --- | --- | +| 1. Config exists on default branch | `gh api repos/diffbot//contents/.github/dependabot.yml` | File present, `version: 2` | +| 2. Config matches policy | Diff against the canonical shape (Β§4). Check ecosystem names, `directory`/`directories`, `schedule`, `allow`, `groups` (`group-by`), `versioning-strategy`, `open-pull-requests-limit`. Ecosystem keys and options from (G1) | No typos. Only Diffbot packages and `github-actions` | +| 3. Config history | `gh api 'repos/diffbot//commits?path=.github/dependabot.yml'` | Matches what was approved | +| 4. Jobs actually run | Dependabot runs as a dynamic Actions workflow `dynamic/dependabot/dependabot-updates` (G3). `gh api repos/diffbot//actions/workflows` β†’ id β†’ `gh api repos/diffbot//actions/workflows//runs` | One run per ecosystem/directory after the config merge, then on schedule. Latest `success` | +| 5. Failure diagnosis | `gh run view --repo diffbot/ --log-failed`, then read the `Errors` table (error type + message) | Error type explains the failure | +| 5b. *UI* | Insights β†’ Dependency graph β†’ Dependabot β†’ *Recent update jobs* β†’ *view logs* (G2). "Check for updates" re-runs a version-update job (G4) | Same as above. Use it to re-trigger after a fix | +| 6. Output | `gh pr list --repo diffbot/ --author app/dependabot --state all` and `gh api repos/diffbot//branches --paginate` (filter `dependabot/`) | PRs only for allow-listed deps. No orphaned branches | +| 7. "No PR" is correct | Compare the manifest range with the latest release (`pypi.org/pypi/diffbot/json`, `registry.npmjs.org/@diffbot%2ftypescript`) | Range already admits latest β†’ no PR expected (`increase-if-necessary`, G1) | +| 8. Security side | `gh api repos/diffbot//dependabot/alerts` and `gh api repos/diffbot/ --jq .security_and_analysis` (admin) | State recorded. Separate from version updates (G5) | + +Doc facts used (G1–G5 in Β§7): + +- Supported ecosystems include `uv` and `pip`. `increase-if-necessary` is supported for npm, pip, and uv. +- `open-pull-requests-limit` defaults to 5 and does not apply to security updates, which have a fixed limit of 10. +- Version updates get a default **3-day cooldown**, which does not apply to security updates. +- `group-by: dependency-name` produces "a single pull request for each dependency update across all specified directories". All directories must use the same ecosystem, and it applies to version updates only. +- `allow` supports `*` wildcards. + +--- + +## 2. Current findings (2026-12-03) + +All 9 repos are public. Config commit for every repo: 2026-11-28 05:48 UTC, one commit, unchanged since. + +| Repo | Config on `main` | Ecosystems (dir) | Latest Dependabot runs | Dependabot PRs | Errors / notes | +| --- | --- | --- | --- | --- | --- | +| `ai-sdk` | βœ… `da4d727` | npm `/`, actions `/` | npm 11-30 βœ…, actions 12-01 βœ…. 6/6 runs success | #7 actions merged | None. `^0.6.0` = latest `@diffbot/typescript` 0.6.0, so no npm PR expected | +| `langchain-diffbot-typescript` | βœ… `448dcff` | npm `/`, `/fixtures/worker`, `/examples/company-research`, `/examples/dql-explorer` (`group-by: dependency-name`), actions | npm (all 4 dirs in one job) 11-30 βœ…, actions 12-01 βœ…. 6/6 success | #9 actions merged | None. All 4 manifests `^0.6.0`. `group-by` not exercised yet. `dependabot_security_updates: disabled` | +| `diffbot-pi` | βœ… `7dfa7b7` | npm `/`, actions | npm 11-30 βœ…, actions 12-01 βœ…. 6/6 success | #6 actions merged | None | +| `langchain-diffbot` | βœ… `43404cb` | **uv** `/`, actions | uv 11-30 βœ…. **uv 11-28 ❌ Γ—2**. actions βœ… | **#9 open**: `diffbot` 3.4.0β†’3.4.1 (uv.lock only, CI green, mergeable). #7 actions merged | 11-28: `path_dependencies_not_reachable` (`langchain-core`, `langchain-tests`). Fixed by #8 (removed `[tool.uv.sources]`). pyproject floor stays `diffbot>=3.4.0,<4`, which is correct under the floor rule | +| `diffbot-mcp` | βœ… `bb779ef` | pip `/` (no lockfile), actions | pip 11-30 βœ…, actions 12-01 βœ…. 7/7 success | **#11 open**: actions group, 5 updates (checkout, rsync-deployments, cosign-installer, setup-uv, setup-python). CI green | ⚠️ #11 touches `main.yml`, and `main.yml` deploys on push to `main`. `diffbot>=3.4.1,<4` = latest, so no pip PR | +| `dify-diffbot` | βœ… `9bd3fe4` | pip `/diffbot`, actions | pip 11-30 βœ…, actions 12-01 βœ…. 6/6 success | #7 actions merged | `diffbot==3.4.1` in both `diffbot/requirements.txt` and `diffbot/pyproject.toml` = latest. Two-file update unverified until the next SDK release | +| `diffbot-skills` | βœ… `b700179` | actions only | 12-01 βœ…. 3/3 success | #4 actions merged | Markdown pins `'diffbot>=3.4.0,<4'` (SKILL.md files, README) already admit 3.4.1, so no hand bump needed | +| `diffbot-typescript` | βœ… `62a78ca` | actions only | 12-01 βœ…. 3/3 success | #11 actions merged | `dependabot_security_updates: disabled` | +| `diffbot-python` | βœ… `d12c72e` | actions only | actions 12-01 βœ…. 2 runs since config | #17 actions merged. #9 (certifi, uv) closed 2026-10-26. #7 (2019, pip) closed | **Stale branch `dependabot/uv/certifi-2026.10.19`.** 15 security-update jobs (`"command":"security"`) ran 2026-05-26 β†’ 10-26, 14 failed (`dependency_file_not_resolvable`, py3.9 split). Alerts API: **403 "Dependabot alerts are disabled for this repository"** | + +Out of scope, recorded only: `diffbot-openclaw` (left alone by policy, not inspected). `codegpt-pi` and `code-gpt-docs` have no `dependabot.yml`; they are not in the 2026-11-27 list (Q5). + +### 2.1 What was blocked + +- **Insights UI** (Dependency graph β†’ Dependabot tab): no browser in the sandbox. The Actions-run API gave the same job history and logs, so nothing material is missing. +- **`security_and_analysis`**: visible for only 2 repos (`langchain-diffbot-typescript`, `diffbot-typescript`, both with security updates disabled). It returned `null` for the other 7, because the token has maintain, not admin. +- **Dependabot alerts:** `0` open for 8 repos (so alerts are enabled there). `diffbot-python` returned 403 because alerts are disabled. +- **`diffbot-dev-docs`** (`docs/conventions/dependabot.md`): not in this checkout, and `diffbot/diffbot-dev-docs` returns 404 (local-only, as expected). This audit relies on the policy in the task and the live configs. + +--- + +## 3. Gaps and recommended fixes (later milestones, not this run) + +| # | Gap | Recommended fix | Priority | +| --- | --- | --- | --- | +| F1 | `diffbot-python` stale branch `dependabot/uv/certifi-2026.10.19` (PR closed 2026-10-26) | Delete the branch. No config change: the actions-only config is right, and the uv jobs were security updates, not version updates | Low, πŸ…° go | +| F2 | `langchain-diffbot` uv job depends on `[tool.uv.sources]` staying out of `pyproject.toml` | Add a one-line comment in `pyproject.toml` or the contributing doc: "no out-of-repo path sources; it breaks Dependabot uv". **Do not** switch to pip: uv works, and pip would stop relocking `uv.lock`. Keep the pip fallback documented only as a contingency | Low | +| F3 | Security updates and alerts are inconsistent: alerts disabled on `diffbot-python`; security updates disabled on at least 2 repos; unknown on 6 | Andrew decides the policy (Q3). If enabled on `diffbot-python`, expect the old py3.9 resolution failures to come back. They need either a `requires-python` decision or `ignore` entries, which belong in a separate SDK decision | Andrew's call | +| F4 | Open PRs `langchain-diffbot#9` and `diffbot-mcp#11` | Andrew merges or closes when convenient. For `diffbot-mcp#11`, treat merge as a production deploy (it edits the deploy workflow's actions) | πŸ…° only | +| F5 | `dify-diffbot` exact pin in two files | After the next `diffbot` release, check once that the Dependabot PR edits both files. If it edits only one, consider pointing the pip job at a single source of truth (needs a design decision; don't pre-empt) | Check once | +| F6 | `group-by: dependency-name` in `langchain-diffbot-typescript` not yet exercised | After the next `@diffbot/typescript` release, check once that there is one PR covering all 4 directories | Check once | +| F7 | `diffbot-skills` Markdown `pip install` lines are invisible to Dependabot (known, accepted gap) | Hand-bump only when the floor rule triggers. Nothing needed now, since `>=3.4.0,<4` admits 3.4.1. **Do not** add a manifest | None now | +| F8 | No config typos, missing repos, or ecosystem errors found among the 9 | None | β€” | + +--- + +## 4. Policy reminders + +- **Allow list:** Dependabot is for Diffbot's own packages only: `@diffbot/*` on npm, `diffbot` on pip/uv. On top of that, one low-noise `github-actions` ecosystem (monthly, grouped, limit 2). It does not lockstep upstream dependencies. +- **Floor rule:** do not bump floors routinely. Raise a floor only when a fresh install would not pick up the latest version, or when a change in that repo actually needs the newer version. That is why configs use `versioning-strategy: increase-if-necessary`. `langchain-diffbot#9` shows this working: lockfile moves, floor stays `>=3.4.0`. +- **No automatic monitoring of Dependabot PRs** (Andrew, 2026-11-28). Check on them as needed. No watcher, digest routine, or babysitting worker. This audit is one-off. +- **The audit itself bumps nothing,** edits no configs, and merges nothing. +- **Leave `diffbot-openclaw` alone.** +- **No package manifest in `diffbot-skills`** just for Dependabot (script-free / Anthropic directory policy). Markdown `pip install` lines are bumped by hand if ever needed. +- **`diffbot-mcp`:** a merge to `main` deploys production. This audit doesn't change deploy behaviour. +- Canonical shape: package ecosystems `schedule.interval: weekly`, `day: monday`, `open-pull-requests-limit: 5`, `versioning-strategy: increase-if-necessary`, `allow` + `diffbot` group. `github-actions` monthly, `open-pull-requests-limit: 2`, group `github-actions` `"*"`. Default ~3-day cooldown (G1). + +--- + +## 5. Phased milestones + +| # | Milestone | Who | Exit criteria | +| --- | --- | --- | --- | +| **A0** | Read this audit; answer Β§6 | πŸ…° | Answers recorded here | +| **A1** | Merge or close `langchain-diffbot#9` and `diffbot-mcp#11` (the latter as a deploy) | πŸ…° only (no bot merges) | Both resolved | +| **A2** | Cleanup PR(s): delete the `diffbot-python` stale branch (F1); `langchain-diffbot` comment about `[tool.uv.sources]` (F2) | πŸ›  prepares; πŸ…° approves the branch deletion and merges | Branch gone; comment merged | +| **A3** | Security-updates and alerts settings per Q3 (admin settings, not YAML) | πŸ…° (admin) | Settings consistent with the decision | +| **A4** | One-off re-check after the next `diffbot` PyPI release and the next `@diffbot/typescript` npm release (F5, F6), using the Β§1 method | πŸ›  when asked | Findings appended to the notes file | +| β€” | Re-run this whole audit | πŸ›  only when Andrew asks | No schedule, per policy | + +--- + +## 6. Open questions for Andrew + +1. **uv fallback:** the uv job on `langchain-diffbot` now works (after #8). OK to keep uv and keep pip only as a documented contingency if `[tool.uv.sources]` ever has to come back? +2. **Open PRs:** merge `langchain-diffbot#9` (lock-only `diffbot` 3.4.1) and `diffbot-mcp#11` (actions bump; merging deploys `mcp.diffbot.com`)? Your call and timing. +3. **Security updates and alerts:** alerts are disabled on `diffbot-python`, and security updates are disabled on at least `langchain-diffbot-typescript` and `diffbot-typescript`. Is that intended? If you want them on, the `diffbot-python` py3.9 split failures will likely recur and need a separate decision. +4. **Stale branch:** OK to delete `dependabot/uv/certifi-2026.10.19` in `diffbot-python`? +5. **Repo list:** should `codegpt-pi` (or any new repo, such as future integration packages like the AgentScope or Microsoft Agent Framework plans) get the same config when created? The default proposal: new Diffbot library repos get the canonical config in their scaffold PR. +6. **Re-proposing configs:** all 9 merged unchanged, so nothing needs re-proposing. Confirm no further changes are wanted to the canonical shape (for example, an explicit `cooldown`). + +--- + +## 7. Sources opened + +| # | Title | URL | +| --- | --- | --- | +| G1 | Dependabot options reference | https://docs.github.com/en/code-security/dependabot/working-with-dependabot/dependabot-options-reference | +| G2 | Viewing Dependabot job logs | https://docs.github.com/en/code-security/dependabot/troubleshooting-dependabot/viewing-dependabot-job-logs | +| G3 | About Dependabot on GitHub Actions runners | https://docs.github.com/en/code-security/dependabot/working-with-dependabot/about-dependabot-on-github-actions-runners | +| G4 | Troubleshooting Dependabot errors | https://docs.github.com/en/code-security/dependabot/troubleshooting-dependabot/troubleshooting-dependabot-errors | +| G5 | Configuring Dependabot security updates | https://docs.github.com/en/code-security/dependabot/dependabot-security-updates/configuring-dependabot-security-updates | +| β€” | GitHub REST API (contents, commits, actions runs, branches, dependabot alerts), via `gh api` | https://docs.github.com/rest | diff --git a/docs/plans/microsoft-agent-framework-integration.md b/docs/plans/microsoft-agent-framework-integration.md new file mode 100644 index 0000000..5aaaf7f --- /dev/null +++ b/docs/plans/microsoft-agent-framework-integration.md @@ -0,0 +1,363 @@ +# Microsoft Agent Framework integration for Diffbot: plan + +> **Status:** plan only. Written 2026-12-03. **Audience:** the implementer (πŸ› ) and Andrew (πŸ…°). +> This PR adds no code, no scaffold, no package, and no published artifacts. Nothing here has been posted to `microsoft/agent-framework`, PyPI, NuGet, or Microsoft Learn. +> Sources, raw findings, and pages that could not be opened: [microsoft-agent-framework-research-notes.md](./microsoft-agent-framework-research-notes.md). +> Sibling plans: [langflow-integration.md](./langflow-integration.md) (PR #18, conventions reused here), [agentscope-integration.md](./agentscope-integration.md), [dependabot-audit.md](./dependabot-audit.md). + +Legend: πŸ…° Andrew must act or approve Β· πŸ›  implementer Β· πŸ…Ή Jerome (only where a Diffbot API fact needs confirming) + +--- + +## 0. TL;DR + +- **Ship a Diffbot-owned Python package on PyPI: `agent-framework-diffbot`** (import `agent_framework_diffbot`), published by Diffbot (`Diffbot `) from a new repo `diffbot/agent-framework-diffbot`. This is the pattern Microsoft's own package design doc uses for connector names (`agent-framework-`), and at least ten vendors already publish their own packages this way. Seven were checked in PyPI metadata (`agent-framework-goodmem`, `-membase`, `-mnemoverse`, `-recallic`, `-plimsoll`, `-botsrated`, `-agent-commerce`), and more are listed in Microsoft's community catalog. Every wheel inspected imports as `agent_framework_`, not `agent_framework.`. No core PR is needed to ship. +- **Tools are plain `FunctionTool`s.** Users pass them to `agent_framework.Agent(..., tools=[...])` or per run with `agent.run(..., tools=[...])`. The package exposes a small `DiffbotTools` class that holds one `DiffbotAsync` client and returns `list[FunctionTool]` from `.tools()`. Vendor peers (`agent-framework-recallic`, `-mnemoverse`, `-agent-commerce`) use the same factory pattern. +- **v0.1 = 7 read-only, single-request tools:** Web Search, Page Extract, Organization Search, Person Search, News Search, KG DQL Query, LLM Ask. This matches the n8n and Langflow v0.1 surface. **Org/Person Enhance are deferred** (Andrew, 2026-12-02). All tools are `async`, set `approval_mode="never_require"` because they are read-only, and validate input with Pydantic models. Org, Person, and News search build escaped DQL. Raw DQL is opt-in and left out of the default tool list. +- **Reuse the official SDK as-is:** `diffbot>=3.4.1,<4` with `DiffbotAsync`. No SDK change is needed. +- **Auth:** resolve the token with MAF's own connector convention, `agent_framework.load_settings(..., env_prefix="DIFFBOT_")`, which checks an explicit `api_token=` argument, then an opt-in `.env` file, then `DIFFBOT_API_TOKEN`. Pass the result to `DiffbotAsync(token=...)`. Never call `diffbot.resolve_token()` and never read `~/.diffbot/credentials`. Apps that keep secrets in Azure Key Vault or similar read the secret themselves and pass `api_token=`. +- **Python only for v0.1.** .NET would be a separate NuGet package. The `Microsoft.*` prefix is reserved on NuGet, so the name would be `Diffbot.*`, and Diffbot has no maintained .NET SDK. It is deferred to a later phase (Q4). +- **The first public step after release is a one-row PR to MAF's community-projects catalog** (`python/samples/community-projects.md`, "Tools" section). Microsoft syncs that file to Learn. It needs Andrew's explicit go. **An upstream package inside `microsoft/agent-framework` is not recommended:** in-repo connectors are authored and released by Microsoft, and non-trivial PRs need a maintainer-approved issue first. +- **Gate:** Andrew creates `diffbot/agent-framework-diffbot` and sets up a PyPI trusted publisher. Until then, M1 is a local spike, and its findings go back into this plan. + +--- + +## 1. Microsoft Agent Framework requirements (as of 2026-12-03) + +Current Python release: **`agent-framework` / `agent-framework-core` 1.26.0** (PyPI, 2026-11-12; GitHub release `python-1.26.0`). Core is `released` and "Production/Stable", MIT, `requires-python >=3.11`. Current .NET release: `Microsoft.Agents.AI` 1.28.0 (NuGet). Official repo: `microsoft/agent-framework` (not archived, pushed 2026-12-03). There is also a Go SDK, `microsoft/agent-framework-go`, which is out of scope. + +### 1.1 Sources actually opened + +| # | Title | URL | +| --- | --- | --- | +| 1 | Repo metadata and `python/packages/` listing | https://github.com/microsoft/agent-framework/tree/main/python/packages | +| 2 | Python Package design for Agent Framework | https://github.com/microsoft/agent-framework/blob/main/docs/design/python-package-setup.md | +| 3 | Python coding standard | https://github.com/microsoft/agent-framework/blob/main/python/CODING_STANDARD.md | +| 4 | `CONTRIBUTING.md` | https://github.com/microsoft/agent-framework/blob/main/CONTRIBUTING.md | +| 5 | `python/AGENTS.md` | https://github.com/microsoft/agent-framework/blob/main/python/AGENTS.md | +| 6 | `python/PACKAGE_STATUS.md` | https://github.com/microsoft/agent-framework/blob/main/python/PACKAGE_STATUS.md | +| 7 | `python/CHANGELOG.md` | https://github.com/microsoft/agent-framework/blob/main/python/CHANGELOG.md | +| 8 | Core public API (`agent_framework/__init__.py`), `_tools.py` (`FunctionTool`, `tool`), `_settings.py` (`load_settings`, `SecretString`), `exceptions.py` | https://github.com/microsoft/agent-framework/tree/main/python/packages/core/agent_framework | +| 9 | Core lazy vendor shims (`agent_framework/mem0/__init__.py`, `agent_framework/tools/__init__.py`) | https://github.com/microsoft/agent-framework/blob/main/python/packages/core/agent_framework/mem0/__init__.py | +| 10 | In-repo connector `pyproject.toml`s (core, tools, mem0, typesafe, nvidia, oracle, mongodb, cohere, mistral, monty) | https://github.com/microsoft/agent-framework/blob/main/python/packages/tools/pyproject.toml | +| 11 | Samples: `01-get-started/02_add_tools.py`, `02-agents/tools/README.md`, `02-agents/tools/tool_in_class.py` | https://github.com/microsoft/agent-framework/tree/main/python/samples/02-agents/tools | +| 12 | Python community-projects catalog | https://github.com/microsoft/agent-framework/blob/main/python/samples/community-projects.md | +| 13 | Community-project catalog review skill (eligibility rules) | https://github.com/microsoft/agent-framework/blob/main/.github/skills/community-projects/SKILL.md | +| 14 | Catalog PRs #10032, #10160, #10270, #10517 | https://github.com/microsoft/agent-framework/pull/10160 | +| 15 | Learn: Tools Overview | https://learn.microsoft.com/en-us/agent-framework/agents/tools/ | +| 16 | Learn: Agent Framework Integrations | https://learn.microsoft.com/en-us/agent-framework/integrations/ | +| 17 | Learn: Tool integrations (by component) | https://learn.microsoft.com/en-us/agent-framework/integrations/by-component/tools/ | +| 18 | Learn: Community projects for Agent Framework | https://learn.microsoft.com/en-us/agent-framework/integrations/community-projects | +| 19 | PyPI simple index (all `agent-framework*` names) and PyPI JSON for ~20 of them | https://pypi.org/simple/ Β· https://pypi.org/pypi/agent-framework-core/json | +| 20 | Wheels (file listing + METADATA only, not executed) of 8 vendor-published `agent-framework-*` packages | e.g. https://pypi.org/project/agent-framework-goodmem/ | +| 21 | PEP 752: Implicit namespaces for package repositories | https://peps.python.org/pep-0752/ | +| 22 | NuGet search API for `Microsoft.Agents.AI*` | https://azuresearch-usnc.nuget.org/query?q=Microsoft.Agents.AI | +| 23 | NuGet ID Prefix Reservation | https://learn.microsoft.com/en-us/nuget/nuget-org/id-prefix-reservation | +| 24 | `diffbot/diffbot-mcp` README (hosted MCP endpoint) | https://github.com/diffbot/diffbot-mcp | + +### 1.2 Requirements that shape the design + +- **Agent and tools API (repo is ground truth):** `from agent_framework import Agent, tool, FunctionTool`. `Agent(client=..., instructions=..., tools=[...])`. Tools can also be passed per call with `agent.run(query, tools=[...])` (11). `@tool(name=, description=, schema=, approval_mode=, max_invocations=, ...)` wraps a sync or async function. `FunctionTool(name=, description=, func=, input_model=, approval_mode=, ...)` is the direct form (8). Bound methods work as tools (`tool_in_class.py`) (11). +- **Input validation:** "Use a Pydantic model when runtime validation matters." JSON-schema dicts get only top-level checks and "must not be treated as an authorization or security boundary" (8, 11). +- **Approval:** the default is `approval_mode="never_require"`. Learn warns: "Tool calls and arguments are generated by the model. Validate and authorize them before application code performs side effects" (15). All Diffbot tools are read-only, so `never_require` fits, but we still validate inputs. +- **Duplicate tool names raise** (`_ensure_unique_tool_names` in `_tools.py`). Prefix our tool names with `diffbot_`. +- **Async:** "Use asynchronous APIs for I/O … Async code MUST NOT block the event loop with synchronous network … work" (3). Use `DiffbotAsync`. +- **Settings:** "Connector constructors MUST use `load_settings` to resolve explicit keyword arguments, an explicitly selected `.env` file, process environment variables, and defaults." An injected client must be accepted without credentials (3). `load_settings` and `SecretString` are exported from the root `agent_framework` package (8). +- **Secrets:** "Secrets, credentials, tokens, and sensitive user content MUST NOT be logged or emitted to telemetry by default" (3). +- **Errors:** core defines `ToolException` and `ToolExecutionException` (8). The coding standard maps "Tool execution failure" to the `ToolException` branch (3). +- **Package layout and naming (2):** connector packages are named `agent-framework-[-]`. For small vendors "we can skip the feature/brand part, so `mem0`, `redis`". In-repo packages import as `agent_framework_`, and core re-exports them lazily from `agent_framework.` through a shim **that lives in core** (9). A third party cannot add `agent_framework.diffbot` without a core PR, and must not install files into core's regular (non-namespace) `agent_framework` package. +- **Python:** core requires `>=3.11` (10). This SDK supports `>=3.9`, so it is compatible. +- **Upstream contribution rules (4):** "Except for trivial changes, create or reuse an issue before starting implementation" and "Wait for a maintainer to add the `ready-for-implementation` label". Non-trivial PRs without an agreed issue "may be closed without detailed review". External PRs that touch `.github/workflows/` "will be closed". "DON'T make new APIs without filing an issue". AI-assisted contributions are allowed under `AI_CONTRIBUTIONS.md` (not opened). +- **Who publishes in-repo packages:** every in-repo `pyproject.toml` checked has `authors = [{ name = "Microsoft", email = "af-support@microsoft.com" }]`, including vendor-contributed connectors (typesafe, nvidia, oracle, mongodb) (10). The design doc says releases go "to pypi" through Microsoft's "ESRP pipeline" (2). +- **Community catalog (12, 13, 18):** a Microsoft-maintained list of "published, community-maintained projects", organized by component (`Tools`, `Context providers`, `Middleware`, …), synced to Learn. Rules: the project must already be published, use neutral wording, and have an `Issues` link to the vendor's own issue-creation URL (`/issues/new` or `/issues/new/choose`). **Excluded:** "MCP servers or gateways that only require Agent Framework's standard MCP client or tool configuration", and "Official Microsoft-owned integrations". Vendors list themselves with a direct one-row PR (PRs #10032, #10160, #10270, merged within minutes). + +### 1.3 What changed recently (docs vs repo; repo is ground truth) + +- [x] **`@ai_function` β†’ `@tool`, `AIFunction` β†’ `FunctionTool`** ([BREAKING], CHANGELOG #3413). The package design doc (2) still shows `@ai_function` and `Agent(model_client=...)`. Current samples use `@tool` and `Agent(client=...)`. +- [x] **`ChatAgent` β†’ `Agent`, `ChatMessage` β†’ `Message`** ([BREAKING], #3747). Some older blog posts and the task's starting notes may still say `ChatAgent`. +- [x] **`create_agent` β†’ `as_agent`** (#3249). +- [x] **The design doc's file tree** (`agent_framework-mem0/`) is stale. Packages ship a top-level `agent_framework_/` module (10, 20). +- [x] **The Learn community page still listed a "Tools" row (Engram) on 2026-11-27.** The repo catalog removed it on 2026-12-03 (PR #10517, "Remove broken community project link"). The repo **Python catalog currently has no Tools section.** A Diffbot row would recreate it. Broken links get rows removed, so the project and issue links must stay live. +- [x] **Microsoft placeholder-registered `agent-framework-*` names on PyPI** on 2025-09-30, all version `0.0.0a1` by Microsoft: `-community`, `-chroma`, `-pinecone`, `-weaviate`, `-milvus`, `-astradb`, `-google`, `-aws`, `-mongodb-atlas`, and others (19). `agent-framework-diffbot` is **not** among them and is unclaimed. +- [x] **The Learn "Tool integrations" page** (dated 2026-07-29) lists only Foundry Toolbox and Shell tools. There are no third-party search or extract tools in Microsoft-owned docs (17). + +--- + +## 2. Scope + +### 2.1 First ship (v0.1): 7 read-only, single-request tools + +| Tool name (model-visible) | Diffbot endpoint | SDK today | +| --- | --- | --- | +| `diffbot_web_search` | `GET llm.diffbot.com/api/v1/web_search` (`text`, `size`, `snippetLength`, `maxTokens`; Bearer) | `web_search()` βœ… | +| `diffbot_extract` | `GET api.diffbot.com/v3/{analyze\|article\|product\|discussion\|job\|image\|video\|list\|event}` (`url`, `timeout`). Markdown via `analyze` + `mode=llm` | `extract(url, api, fmt)` βœ… | +| `diffbot_search_organizations` | `POST kg.diffbot.com/kg/v3/dql`, `type:Organization` built from name, homepage, industry, city/country, employee/revenue ranges, public/private | `dql()` βœ… + builder (integration) | +| `diffbot_search_people` | DQL `type:Person` from name, employer, title, city/country | `dql()` βœ… + builder | +| `diffbot_search_news` | DQL `type:Article` from mentions, text, title, publisher, language, since/until | `dql()` βœ… + builder | +| `diffbot_dql` *(opt-in)* | `POST kg/v3/dql` with raw query, `size`, `from` | `dql(query, size=, from_=)` βœ… | +| `diffbot_ask` | `POST llm.diffbot.com/rag/v1/chat/completions` (`diffbot-small-xl`, SSE, optional `response_format` json_schema) | `ask()` / `ask_json()` βœ… | + +Verified in this checkout (`diffbot` 3.4.1, `src/diffbot/client.py`): + +- `DiffbotAsync(token, *, timeout, retry, …, transport)` raises `ValidationError` on an empty token and does **not** call `resolve_token()`. +- It exposes async `extract`, `ask` (async iterator of text chunks), `ask_json`, `web_search`, `dql`, `dql_parallel`, `crawl*`, `account`, `verify_token`, `entities`, `nlp`, ontology helpers, `request()`, and `close()`. +- There are no structured DQL builders and no Enhance wrapper. +- User-Agent is fixed at `diffbot-python/`. + +### 2.2 Deferred, with reasons + +| Capability | Why deferred | +| --- | --- | +| Organization Enhance, Person Enhance | **Deferred by Andrew (2026-12-02).** This matches Jerome's 2026-11-17 view that Enhance is "bloat for the LLM", and Dify's scope. Org/Person Search already find entities. No SDK `enhance()` is needed. Revisit only if users ask for enrichment. Research found no MAF-specific reason to change this. | +| Crawl (`crawl*`) | Async multi-minute jobs. A function tool would block the agent loop. MAF has workflows and long-running hosting, but that is a different contract. Revisit as a start/poll tool pair or a workflow executor. | +| Bulk Enhance | Async job, the same problem as crawl. | +| Account / usage as a tool | Not an agent task. `verify_token()` may back an optional `await DiffbotTools.check()` helper later (not a tool). | +| Ontology fetch as a tool | Metadata, not data. Builders embed enums at build time. | +| NLP / entities | Not in the n8n/Langflow v0.1 surface. Keep parity first. | +| Context provider (`ContextProvider` subclass that pre-fetches Diffbot results before a run) | A real MAF extension point (`agent-framework-recallic` / `-mnemoverse` ship one), but it's a different UX: automatic retrieval vs model-chosen tools. Consider for 0.2 (Q6). | +| Middleware, chat client for Diffbot LLM | The Diffbot LLM endpoint is OpenAI-compatible at the chat-completions level. If users want it as a *model*, the existing `OpenAIChatCompletionClient` with a custom base URL may already work. The catalog explicitly excludes such "OpenAI-compatible endpoint" integrations (13). v0.1 exposes Ask as a tool only. | +| Streaming Ask tokens to the caller | v0.1 collects the SSE stream into one string, because a tool result is a single value. | +| .NET package | Β§4.11 and Q4. | + +--- + +## 3. Dependency decision: reuse the `diffbot` SDK + +**Decision: depend on `diffbot>=3.4.1,<4` and use `DiffbotAsync`.** Do not hand-roll HTTP. + +- MAF connectors depend on vendor SDKs as required dependencies. The design doc says "All dependencies for a subpackage should be required dependencies in that package" (2). Vendor peers do the same (`agent-framework-agent-commerce` depends on `agent-commerce-client`) (20). +- The SDK already handles Bearer vs `token=` per host, `snippetLength=full` β†’ `rerank=none`, Markdown extract via `mode=llm`, the DQL JSON body, SSE parsing, `json_schema_format`, retries, and typed errors. +- The MAF coding standard requires async I/O (3). `DiffbotAsync` mirrors every method we need. +- `httpx` is the only notable transitive dependency. `click` and `rich` come with the SDK's CLI and are small. + +Other dependencies: `agent-framework-core>=1.26,<2`. Depend on core, not the `agent-framework` meta package, as every vendor peer inspected does (20). Pydantic comes from core. + +| Gap | Decision | +| --- | --- | +| Structured DQL builders and escaping | **Live in the integration** (`_dql.py` with table tests), as in the Langflow plan. Promote to the SDK only if a second Python consumer needs it. Standing policy: don't expand SDK coverage without a real need. | +| Token resolution | `load_settings` (MAF) β†’ `DiffbotAsync(token=...)`. Never `resolve_token()`. | +| User-Agent attribution | The SDK sends `diffbot-python/`. MAF's own clients add `agent-framework-python` to their User-Agent (2). Whether Diffbot wants `agent-framework-diffbot/` for analytics is Q7. It would be a small, separate SDK option and doesn't block v0.1. | + +--- + +## 4. Tool design + +### 4.1 One toolkit object, several focused tools + +**Recommendation: one `DiffbotTools` class whose `.tools()` returns 6 `FunctionTool`s by default (7 with `include_dql=True`).** Do not build one mega-tool with an `operation` argument. + +- MAF tools are independent functions with their own schema and description. The model routes on the description (15). A single tool with an operation enum gives the model one tool with a union of irrelevant arguments. n8n and Langflow both split by operation for the same reason. +- Sharing one `DiffbotAsync` across tools needs an object that owns the client lifecycle. That is the `tool_in_class.py` pattern (11), and vendor peers return `list[FunctionTool]` from a factory: `RecallicContextProvider.tools()`, mnemoverse `_tools.py`, `agent_commerce_tools()` (20). +- Also export each tool as a standalone factory (`web_search_tool(client)`, …) so users can pick one without the class. +- Raw DQL is **opt-in** (`include_dql=True`). Models write poor DQL, and the structured search tools cover the common cases. + +Intended usage (illustrative only, not code in this PR): + +```python +from agent_framework import Agent +from agent_framework_diffbot import DiffbotTools + +async with DiffbotTools() as diffbot: # token from DIFFBOT_API_TOKEN or api_token=... + agent = Agent(client=..., instructions="...", tools=diffbot.tools()) + print(await agent.run("Who is the CEO of Diffbot, and what has the company announced lately?")) +``` + +### 4.2 Layout + +- Repo `diffbot/agent-framework-diffbot` (πŸ…° creates). Distribution `agent-framework-diffbot` β†’ module `agent_framework_diffbot/`. +- Module layout follows the design doc: a folder with an `__init__.py` that exposes the public interface (`__all__`) and private `_files.py` modules (2): + - `__init__.py`: `DiffbotTools`, `DiffbotSettings`, the per-tool factories, `__version__`. + - `_toolkit.py`: the class, client lifecycle, and `load_settings`. + - `_tools.py`: the 7 async functions, Pydantic input models, descriptions, and result shaping. + - `_dql.py`: builders and escaping. + - `_errors.py`: SDK error β†’ `ToolExecutionException` mapping. + - `py.typed`. +- `pyproject.toml`: hatchling (or uv_build). `requires-python >=3.11`. Dependencies `agent-framework-core>=1.26,<2` and `diffbot>=3.4.1,<4`. Authors `Diffbot `. MIT licence (Q2). Classifiers matching MAF peers. Project URLs include `Issues = https://github.com/diffbot/agent-framework-diffbot/issues`, which the catalog row needs. +- Logging: a single `logging.getLogger("agent_framework_diffbot")`. MAF's `get_logger` convention applies to in-repo code. Mirroring it is optional for an external package (verify in M1). + +### 4.3 Auth and credentials + +- `DiffbotTools(api_token: str | None = None, *, client: DiffbotAsync | None = None, env_file_path: str | None = None, timeout: float | None = None)`. +- Resolution follows the MAF coding standard's connector pattern (3), shown here as prose rather than code: call `load_settings(DiffbotSettings, env_prefix="DIFFBOT_", required_fields=[] if client else ["api_token"], api_token=api_token, env_file_path=env_file_path)`. Then build `DiffbotAsync(token=settings["api_token"].get_secret_value())`, or use the injected `client`. The env var resolves to `DIFFBOT_API_TOKEN`, the same name the rest of Diffbot's tooling uses, but here it is read by **MAF's** settings loader. +- **Never** call `diffbot.resolve_token()`, which would add a silent fallback to `~/.diffbot/credentials`. Never read machine-local credential files. +- Azure Key Vault, Foundry project secrets, or any app secret store: the app reads the secret and passes `api_token=`. The README shows this. No Azure dependency in the package. +- The token is never a tool argument, so it is never model-visible. It is held as `SecretString` until the client is built (`str()`/`repr()` mask it) (8). Never log it or put it in exception text. +- If no token is available, fail at construction with a clear message. This is before any agent run, and follows "Invalid combinations MUST fail before execution" (3). + +### 4.4 Tool signatures, descriptions, results + +- **Async functions with Pydantic input models.** Only natural-language arguments are model-facing: + - `query` for web search + - `url` plus an optional `page_type` enum for extract + - name/homepage/industry/location/size fields for org search + - name/employer/title/location for person search + - mentions/text/title/publisher/language/since/until for news search + - `question` plus an optional JSON schema for ask + Limits like `size`, `timeout`, and `max_tokens` are constructor settings with model-facing caps, not free arguments. This keeps schemas small and stops a model from requesting 1,000 results. +- **Descriptions** are the routing signal. Write them per tool, concrete about what Diffbot is good at. The DQL description says it expects valid DQL and is for experts. +- **Results:** return compact JSON strings. Trim KG entities to a documented field subset, and give extract the Markdown body plus title/url. This keeps token use predictable. Use `result_parser` or shape the result in the function; the docstring recommends the latter (8). +- **Ask:** collect `DiffbotAsync.ask()` chunks into one string. With a schema, use `ask_json(schema=...)` and return JSON. +- **Errors:** map `diffbot.errors` (401/403 β†’ "check DIFFBOT_API_TOKEN", 429 β†’ rate-limited, timeouts) to `ToolExecutionException` with a short, token-free message. Confirm in M1 how MAF surfaces a raised exception to the model, versus returning an error string as in `function_tool_recover_from_failures.py` (11). +- `approval_mode="never_require"` on all tools (read-only). Users who want human review can wrap them with `ToolApprovalMiddleware` without package changes. + +### 4.5 Structured search β†’ DQL (injection-safe) + +The same rules as the Langflow plan Β§4.5. Copy the field mapping from the n8n v0.1 implementation; πŸ…Ή confirms only if n8n and the current ontology disagree. + +- Free text becomes quoted DQL string literals with `\` and `"` escaped. Newlines are rejected. +- Enumerated fields (industry, country, language, public/private, size buckets) are `Literal`/`Enum` in the Pydantic model, so validation rejects anything else before a request is made. +- Numbers are range-checked. Dates are ISO-8601, parsed and re-serialised. +- Hostile-input table tests: `foo" OR type:Person`, backslashes, unicode, empty strings. + +### 4.6 Icons + +Not applicable. MAF is a code-first SDK with no tool palette. The catalog row has no icon field (12). + +### 4.7 Testing + +- **Unit (offline, always):** pytest + pytest-asyncio. + - Build `DiffbotAsync(token="test", transport=httpx.MockTransport(...))` and inject it with `client=`. + - Assert each `FunctionTool`'s name, description, and JSON schema (`FunctionTool.parameters()` or equivalent; confirm the exact accessor in M1). + - Invoke each tool via `await tool.invoke(arguments=...)` (8) and check the request URL/params and the result shape. + - DQL builder table tests and error mapping. + - Confirm the token never appears in logs, `repr`, or exception text. +- **Agent loop test:** run one `Agent` turn with a stub chat client that emits a function call for `diffbot_web_search`, and check that the tool result flows back. M1 checks whether core ships a reusable test or mock chat client. Otherwise implement a minimal `SupportsChatGetResponse` stub. +- **Live tests (manual or scheduled, opt-in):** a few calls with repo secret `DIFFBOT_API_TOKEN`, following this repo's `live-tests.yml` pattern. Never on fork PRs. +- **Compat job:** weekly, against the latest `agent-framework-core` (and `--prerelease=allow`) to catch breaking renames. The CHANGELOG shows several in 2026 (Β§1.3). + +### 4.8 CI (GitHub Actions in the Diffbot repo) + +- `tests.yml` on push/PR: `uv sync --frozen`, ruff, pyright, pytest on Python 3.11–3.14. MAF runs mypy + pyright (2). Pyright alone matches this repo. +- Dependabot: follow the Diffbot convention (allow-list `diffbot` on pip/uv, plus monthly grouped github-actions). See [dependabot-audit.md](./dependabot-audit.md). Don't bump floors routinely. + +### 4.9 Docs + +- README covering: + - install (`pip install agent-framework-diffbot`) + - token setup (`DIFFBOT_API_TOKEN`, `.env` via `env_file_path`, explicit `api_token=` from Key Vault or similar) + - one section per tool + - the `include_dql` caveat + - a full `Agent` example with an OpenAI or Foundry client + - picking a subset of tools + - an approval-middleware note + - **"Already using MCP?"**: MAF can call Diffbot's hosted MCP server (`https://mcp.diffbot.com/mcp`) through `MCPStreamableHTTPTool` with no package (24). Explain when to prefer the package: typed tools, no MCP hop, the v0.1 subset only. +- `samples/` in the Diffbot repo: one runnable script per common scenario (research agent, company lookup). +- Link from this SDK's README only after the first release (separate PR, Andrew's call). + +### 4.10 Release and publish + +- Copy this repo's `release.yml`: tag-triggered, **PyPI trusted publishing (OIDC)**, no stored token, `workflow_dispatch` dry run. +- **No RC process.** The package is not on npm and has no dependent repos, so under Diffbot's policy it ships stable releases directly: `0.1.0` β†’ tag `v0.1.0` β†’ PyPI + GitHub release, **only after Andrew's go.** Before tagging, run `uv build` and `twine check`, and smoke-install the wheel in a clean venv. +- Version sync check: `pyproject.toml` version == tag. SemVer 0.x until tool names and schemas settle. **Tool names are a public contract** (users' prompts and approval rules reference them), so renames are breaking. +- Optional later: PEP 740 attestations come with trusted publishing via `pypa/gh-action-pypi-publish`. Nothing extra is needed. + +### 4.11 Later phase: .NET (not v0.1) + +- **Shape:** MAF .NET tools are `AIFunction`s from `Microsoft.Extensions.AI`, for example `AIFunctionFactory.Create(GetWeather)` passed as `tools: [...]` to `AsAIAgent(...)` (15). A Diffbot .NET package would expose `IEnumerable`. That works with MAF and with anything else built on `Microsoft.Extensions.AI`. +- **Naming:** `Microsoft.Agents.AI.*` packages are owned by the `Microsoft`/`MicrosoftAgentFramework` NuGet accounts and show `verified: true` (22). NuGet rejects packages that match a reserved prefix "unless it originates from the owner(s) that reserved the ID prefix" (23). So Diffbot cannot use `Microsoft.Agents.AI.Diffbot`. Third parties use their own prefix (`CommunityToolkit.*`, `DeepSeek.Agents.AI`, `Elastic.SemanticKernel.Connectors.*`) (18, 22). Candidate: **`Diffbot.Agents.AI`** (mirrors the MAF namespace) or `Diffbot.Extensions.AI` (framework-agnostic). Decide in the .NET phase. πŸ…° may want to reserve the `Diffbot.*` prefix on NuGet at that point (an outward step). +- **Blocker:** Diffbot has no maintained .NET SDK. `diffbot/diffbot-csharp-client` is a legacy repo, not evaluated. A .NET port means raw `HttpClient` or a new SDK, against the "don't expand SDK coverage unless needed" policy. A Python-only package is **not** a dead end: Python and .NET are separate catalogs (12, 13), and Python vendor packages exist without .NET twins. + +--- + +## 5. Peer comparison + +### 5.1 Search / extract / KG analogues already in MAF + +| Peer | Where | Shape | Notes for Diffbot | +| --- | --- | --- | --- | +| **Hosted Web Search** (`SupportsWebSearchTool`) | core, per provider | Provider-side tool, executed by OpenAI/Foundry/Anthropic, not local code | Only on some clients (the Python matrix shows βœ… for Responses, Chat Completion, Foundry, and Anthropic, and ❌ for Ollama, Foundry Local, and GitHub Copilot) (15). Diffbot is a local function tool and works with **any** client that supports function tools. That's a selling point for Ollama and Foundry Local users. | +| **Bing Grounding / Bing Custom Search** | Foundry only, experimental/preview | Hosted | Needs an Azure resource. Diffbot needs no Azure. | +| **Foundry IQ (Azure AI Search)**, `agent-framework-azure-ai-search` | Microsoft package | Context provider / hosted | Private-index RAG, not web or KG. | +| **MCP tools** (`MCPStreamableHTTPTool`, `MCPStdioTool`) | core | Generic client | Already lets MAF users reach `diffbot-mcp` today (24). The catalog excludes MCP-only integrations (13), which is one reason to ship a native package. | +| **Shell tools**, `agent-framework-tools` | Microsoft package | Local tools | Shows Microsoft's own "tools package" layout. | + +No third-party web search, extraction, or KG tool package was found in the MAF catalog or the `agent-framework-*` PyPI names (19). Diffbot would be the first in the "Tools" category with a data/search focus. + +### 5.2 How vendors package MAF integrations + +| Package | Publisher | Import | Shape | Catalog | +| --- | --- | --- | --- | --- | +| `agent-framework-goodmem` 0.2.0 | GoodMem (`support@goodmem.ai`), repo `bashareid/goodmem_agent-framework` | `agent_framework_goodmem` | memory | β€” | +| `agent-framework-membase` 0.2.1 | Membase | `agent_framework_membase` | context provider + tools | βœ… Context providers | +| `agent-framework-mnemoverse` 0.1.0 | Mnemoverse | `agent_framework_mnemoverse` | `@tool` functions β†’ `list[FunctionTool]`; `MNEMOVERSE_API_KEY` env fallback | β€” | +| `agent-framework-recallic` 0.1.2 | Recallic (Apache-2.0) | `agent_framework_recallic` | context provider with `.tools() -> list[FunctionTool]` | β€” | +| `agent-framework-agent-commerce` 0.1.1 | ACG (Apache-2.0) | `agent_framework_agent_commerce` | `async def agent_commerce_tools() -> list[FunctionTool]` | β€” | +| `agent-framework-botsrated` 0.1.6 | BotsRated | `agent_framework_botsrated` | middleware + one tool | βœ… Middleware | +| `agent-framework-plimsoll` 0.32.0 | Plimsoll | `agent_framework_plimsoll` | depends on core + tools | β€” | +| `agent-framework-bhived`, `-dxmt`, `-memorysync`, `-acgs` | respective vendors | (not inspected) | context providers / middleware | βœ… | +| `supermemory-agent-framework` | Supermemory | (not inspected) | context provider + tools + middleware | βœ… (the only vendor-first name in the catalog) | + +Takeaways: + +- `agent-framework-` with import `agent_framework_` is the dominant vendor convention. In the current repo catalog, 6 of the 9 entries that name a package use it (bhived, dxmt, membase, memorysync, acgs, botsrated). The others are `supermemory-agent-framework`, `tracekit-ai`, and `donkey-kit`. All 7 vendor wheels inspected import as `agent_framework_`. +- Depend on `agent-framework-core`, not the meta package. +- Expose tools as `list[FunctionTool]` from a factory or class. +- The catalog is the only Microsoft-curated listing open to vendors. + +--- + +### 5.3 Distribution: where the code lives (primary path) + +**Recommendation: (1) a Diffbot-owned `agent-framework-diffbot` on PyPI, then (3) a community-catalog row after release.** + +| Option | Verdict | Why | +| --- | --- | --- | +| **1. Diffbot-owned package `agent-framework-diffbot`** | βœ… **Primary** | Follows the design doc's naming (2) and matches what vendors already do (Β§5.2). No core PR, no Microsoft release coupling, and Diffbot controls fixes and versions. `pip install agent-framework-diffbot` reads like a first-class connector. Name unclaimed on PyPI as of 2026-12-03 (19). PyPI does not enforce prefix ownership today. PEP 752 (accepted 2026-06-29) would let an org reserve a prefix, but its deployment on PyPI is unconfirmed, so this is a risk to watch (Q1b). | +| **2. Upstream package in `microsoft/agent-framework/python/packages/diffbot`** | ❌ Not recommended | In-repo packages are authored and published by Microsoft (`af-support@microsoft.com`, ESRP) even when vendors contribute them (typesafe, nvidia, oracle, mongodb) (2, 10). Diffbot would give up release control. It needs an issue labelled `ready-for-implementation` first (4), plus a core shim for `agent_framework.diffbot` (9). The catalog excludes "Official Microsoft-owned integrations", so this would also lose the catalog listing. The `agent-framework-*` name is not reserved, but the `agent_framework.` import path is: it needs core's shim. Revisit only if Microsoft invites it. | +| **3. Community-projects catalog row** (`python/samples/community-projects.md` β†’ Learn) | βœ… **After 0.1.0** (Andrew-gated) | The only Microsoft-curated listing for third parties (12, 13, 18). Eligible only once published. Neutral wording. `Issues` link `https://github.com/diffbot/agent-framework-diffbot/issues/new`. A direct one-row PR is the norm (#10032, #10160, #10270). Section: **Tools** (currently empty in the repo after #10517). | +| **4. Samples/docs-only contribution** to `microsoft/agent-framework` samples | ❌ No | Samples there demonstrate Microsoft features. A vendor sample would be "new API" or non-trivial content needing an issue first (4). The catalog is the sanctioned route. Samples live in Diffbot's repo instead. | +| **5. MCP only** (point MAF users at `diffbot-mcp` via `MCPStreamableHTTPTool`) | Interim / complementary | Works today with zero code (24). Document it in the Diffbot README and docs site. Not catalog-eligible (13). It gives a different tool set (includes crawl and entities). Not a substitute for typed in-process tools. | +| **6. `.NET` NuGet package** | Later (Β§4.11) | Needs a `Diffbot.*` name and an HTTP layer. Separate catalog. | + +**Before the repo exists:** no SDK work is needed. The M1 spike runs in a scratch directory, not committed anywhere public. No integration code lands in `diffbot-python` (its `release.yml` tags `v*` for the SDK). + +--- + +## 6. Phased milestones + +| # | Milestone | Who | Exit criteria | +| --- | --- | --- | --- | +| **M0** | Decisions: package/repo name (Q1), licence (Q2), confirm v0.1 = 7 tools, Python only (Q3), catalog authorization (Q5) | πŸ…° | Answers recorded in this doc | +| **M1** | **Local spike** (no publish, no repo): `diffbot_web_search` + `diffbot_extract` as `FunctionTool`s on `agent-framework-core` 1.26.x with `DiffbotAsync`. Confirm `load_settings`/`SecretString` usage from an external package, the schema accessor, exception-to-model behaviour, a stub chat client for the loop test, and Pydantic input models with async functions | πŸ›  locally | Findings appended to research notes; Β§4 amended | +| **M2** | **Repo + scaffold:** create `diffbot/agent-framework-diffbot`, enable Actions, PyPI pending trusted publisher for `agent-framework-diffbot`, branch protection, enable Issues (catalog needs the issue link) | πŸ…° creates; πŸ›  scaffolds via PR | `tests.yml` green on the skeleton | +| **M3** | **v0.1 tools:** all 7, DQL builders + injection tests, README, samples | πŸ›  PRs; πŸ…° reviews and merges (no bot merges) | Unit + loop tests green; one manual live run recorded | +| **M4** | **Release 0.1.0** (stable, no RC) | πŸ…° go; πŸ›  tags | On PyPI; clean-venv install works with an OpenAI or Foundry client | +| **M5** | *(Gated)* Community catalog PR: one row under **Tools** in `python/samples/community-projects.md` | πŸ…° **explicit go**; πŸ›  drafts the row text for review first | Merged by MAF maintainers; appears on Learn after sync | +| **M6** | *(Later, optional)* Context provider (Q6), User-Agent suffix (Q7) | πŸ› , πŸ…° | β€” | +| **M7** | *(Later, optional)* .NET package (Β§4.11, Q4) | πŸ…° decides; πŸ›  | Separate plan | +| β€” | DQL field names disagree between n8n and the ontology | πŸ…Ή only if triggered | Confirmed field list | + +--- + +## 7. Open questions for Andrew + +1. **Package / repo name and author.** Recommend `agent-framework-diffbot` (import `agent_framework_diffbot`, repo `diffbot/agent-framework-diffbot`, author `Diffbot `). The alternative `diffbot-agent-framework` (the Supermemory style) is safer if Microsoft ever enforces the prefix, but it's less discoverable and less common (1 catalog entry uses it, vs 6 for `agent-framework-`). + - **1b.** Accept the risk that Microsoft could later reserve `agent-framework-` under PEP 752? Its effect on existing third-party names is unverified. +2. **Licence:** MIT, matching this SDK and MAF? +3. **Confirm v0.1** = the 7 tools (raw DQL opt-in), Python only, Enhance deferred. +4. **.NET:** schedule a port at all? If yes, accept that it needs an HTTP layer (no maintained Diffbot .NET SDK), and choose `Diffbot.Agents.AI` vs `Diffbot.Extensions.AI`. +5. **Upstream authorization:** after 0.1.0, is the community-catalog PR to `microsoft/agent-framework` authorized? This needs explicit go. A core package PR is not recommended. Should we ever pursue one if Microsoft asks? +6. **Context provider in 0.2?** An automatic "ground with Diffbot before each run" provider, as memory vendors ship. +7. **Attribution:** do we want an `agent-framework-diffbot/` User-Agent suffix? It would be a small separate SDK option and doesn't block v0.1. +8. **MCP messaging:** should the README lead with the native package, or present hosted `diffbot-mcp` as the zero-install option first? + +--- + +## 8. Recommended first milestone + +**M0 + M1.** Andrew answers Q1–Q3 and Q5. The implementer runs a local spike: `diffbot_web_search` and `diffbot_extract` as async `FunctionTool`s with Pydantic input models, on `agent-framework-core` 1.26.x, using `DiffbotAsync` from released `diffbot` 3.4.x, with the token from `load_settings(env_prefix="DIFFBOT_")`. The spike confirms the settings API from an external package, exception surfacing to the model, schema inspection for tests, and a stub chat client for an offline agent-loop test. Findings go into the research notes and Β§4. This needs no new repo, no SDK change, and no outward post. Meanwhile πŸ…° creates `diffbot/agent-framework-diffbot` so M2 can start as soon as the spike lands. + +--- + +## 9. Outward-facing steps (each needs Andrew's explicit go; none are done in this PR) + +| Step | Gate | Notes | +| --- | --- | --- | +| Create public repo `diffbot/agent-framework-diffbot` | M2, πŸ…° | Org action. Public on creation. | +| Register a PyPI pending trusted publisher / claim the `agent-framework-diffbot` name | M2, πŸ…° | Claims a public name. | +| Publish `agent-framework-diffbot` 0.1.0 to PyPI and create the GitHub release | M4, πŸ…° | First public artifact. | +| PR adding a row to `microsoft/agent-framework` `python/samples/community-projects.md` (syncs to Learn) | M5, πŸ…° | Only after 0.1.0 is live. Neutral wording. Issues link to Diffbot's repo. | +| Any issue or PR proposing an in-repo `python/packages/diffbot` or an `agent_framework.diffbot` shim | πŸ…° (not recommended) | Requires a maintainer-approved issue first (4). | +| Link the package from Diffbot docs, this SDK's README, or `diffbot-mcp` docs | πŸ…° | Separate PRs. | +| NuGet `Diffbot.*` prefix reservation request / .NET package publish | M7, πŸ…° | Only if the .NET phase is approved. | +| Social posts, blog, stars, or Discord announcements | πŸ…° | Not planned by this document. | diff --git a/docs/plans/microsoft-agent-framework-research-notes.md b/docs/plans/microsoft-agent-framework-research-notes.md new file mode 100644 index 0000000..8d81460 --- /dev/null +++ b/docs/plans/microsoft-agent-framework-research-notes.md @@ -0,0 +1,80 @@ +# Microsoft Agent Framework integration: research notes + +> Companion to [microsoft-agent-framework-integration.md](./microsoft-agent-framework-integration.md). Collected 2026-12-03. +> +> These are raw findings, citations, and material that didn't belong in the plan. "βœ… opened" means the page or file was fetched during this run, using `gh api` (read-only) for GitHub and a web fetch for Learn, PyPI, and NuGet. Quotes are verbatim from fetched content. Paraphrases are marked as such. +> +> Vendor wheels were downloaded only to list file names and read `METADATA` and `.py` text. Nothing was installed or executed. + +## 1. Pages and files opened + +| Source | URL | Status | Key findings | +| --- | --- | --- | --- | +| Repo metadata | https://github.com/microsoft/agent-framework | βœ… | `microsoft/agent-framework`, default branch `main`, not archived, last push 2026-12-03. | +| `python/packages/` listing | https://github.com/microsoft/agent-framework/tree/main/python/packages | βœ… | a2a, ag-ui, anthropic, azure-ai-search, azure-contentunderstanding, azure-cosmos-memory, azure-cosmos, azure-documentdb, bedrock, chatkit, claude, cohere, copilotstudio, core, declarative, devui, duckdb, foundry, foundry_hosting, foundry_local, gemini, github_copilot, hosting-a2a, hosting-mcp, hosting-responses, hosting-telegram, hosting, hyperlight, lab, mem0, mistral, mongodb, monty, nvidia, ollama, openai, oracle, orchestrations, postgres, purview, qdrant, redis, sql-server, tools, typesafe. No search, scrape, or KG vendor package. | +| Package design doc | https://github.com/microsoft/agent-framework/blob/main/docs/design/python-package-setup.md | βœ… (273 lines) | "a package name is `-` … For smaller vendors … we can skip the feature/brand part, so `mem0`, `redis`". "we will use namespace packages for connectors, in principle this only includes the packages that we will develop in our repo". "All dependencies for a subpackage should be required dependencies in that package". "Integrations that are outside Microsoft and where we might not always be able to fast-follow breaking changes, will stay as sub-packages". Release: "call into Azure DevOps to use the ESRP pipeline to publish to pypi". User-Agent: "headers with user-agent strings … `agent-framework-python` and the version". **Stale:** sample uses `ai_function` and `Agent(model_client=...)`. The file tree shows `agent_framework-mem0/`. Refers to ADR-0008 (not opened). | +| `python/CODING_STANDARD.md` | https://github.com/microsoft/agent-framework/blob/main/python/CODING_STANDARD.md | βœ… (486 lines) | "Use asynchronous APIs for I/O and concurrency." "Async code MUST NOT block the event loop with synchronous network…". "Connector constructors MUST use `load_settings` to resolve explicit keyword arguments, an explicitly selected `.env` file, process environment variables, and defaults". Example with `env_prefix="PROVIDER_"`, `required_fields=[] if client is not None else ["api_key"]`, `SecretString.get_secret_value()`. "Secrets, credentials, tokens, and sensitive user content MUST NOT be logged or emitted to telemetry by default." "Tool execution failure β†’ `ToolException` branch". "Inputs from users, external services, files, environment variables, and other trust boundaries MUST be validated." | +| `CONTRIBUTING.md` | https://github.com/microsoft/agent-framework/blob/main/CONTRIBUTING.md | βœ… (310 lines) | "Except for trivial changes, create or reuse an issue before starting implementation." "Wait for a maintainer to add the `ready-for-implementation` label…". "Pull requests for non-trivial changes may be closed without detailed review when they are neither linked to an agreed issue…". "Changes to GitHub Actions workflows under `.github/workflows/` are reserved for the repository's maintainer team." "**DON'T** make new APIs without filing an issue and discussing with us first." "If you find third-party code that may fit Agent Framework, file an issue and start a discussion before proceeding." AI-assisted contributions are permitted per `AI_CONTRIBUTIONS.md` (❌ not opened). | +| `python/AGENTS.md` | https://github.com/microsoft/agent-framework/blob/main/python/AGENTS.md | βœ… | "Core uses lazy loading via `__getattr__` in provider folders (e.g., `agent_framework/azure/`)". PR template guidance. Function-calling-loop changes need extra review, and "External contributors must check with the Agent Framework core team before picking up issues in this area." | +| `python/PACKAGE_STATUS.md` | https://github.com/microsoft/agent-framework/blob/main/python/PACKAGE_STATUS.md | βœ… | Buckets: alpha, beta, rc, released. `agent-framework`, `-core`, `-foundry`, `-declarative`, `-ag-ui`, and `-github-copilot` are `released`. Most connectors are beta or alpha. Only `released` packages are covered by the Griffe API-compat check. | +| `python/CHANGELOG.md` | https://github.com/microsoft/agent-framework/blob/main/python/CHANGELOG.md | βœ… | Latest `[1.26.0] - 2026-11-12`. Breaking renames: `@ai_function` β†’ `@tool`, `AIFunction` β†’ `FunctionTool` (#3413). `ChatAgent` β†’ `Agent`, `ChatMessage` β†’ `Message` (#3747). `create_agent` β†’ `as_agent` (#3249). `AgentRunContext` β†’ `AgentContext` (#3714). | +| GitHub releases | https://github.com/microsoft/agent-framework/releases | βœ… (API) | `python-1.26.0` 2026-11-13, `python-1.25.0` 2026-11-07, `dotnet-1.28.0` 2026-11-06. | +| Core `__init__.py` | https://github.com/microsoft/agent-framework/blob/main/python/packages/core/agent_framework/__init__.py | βœ… | Lazy exports include `Agent`, `BaseAgent`, `RawAgent`, `FunctionTool`, `tool`, `ToolTypes`, `normalize_tools`, `FunctionInvocationContext`, `MCPStdioTool`, `MCPStreamableHTTPTool`, `MCPWebsocketTool`, `SecretString`, `load_settings`, `ToolApprovalMiddleware`, `SupportsWebSearchTool`, `SupportsMCPTool`. | +| Core `_tools.py` | https://github.com/microsoft/agent-framework/blob/main/python/packages/core/agent_framework/_tools.py | βœ… (6,759 lines; read the `FunctionTool` and `tool` docstrings) | `FunctionTool(*, name, description="", approval_mode=None, kind=None, max_invocations=None, max_invocation_exceptions=None, additional_properties=None, func=None, input_model=None, result_parser=None)`. `tool(func=None, *, name, description, schema, approval_mode, kind, max_invocations, max_invocation_exceptions, additional_properties, result_parser)`. The default approval is `"never_require"`. "Async functions are also supported". Dict schemas get "lightweight top-level checks … Use a Pydantic model when runtime validation matters". `_ensure_unique_tool_names` and `_raise_duplicate_tool_name` exist. "Direct calls to `FunctionTool.invoke` do not enforce `approval_mode`." | +| Core `_settings.py` | https://github.com/microsoft/agent-framework/blob/main/python/packages/core/agent_framework/_settings.py | βœ… | `load_settings(settings_type, *, env_prefix="", env_file_path=None, env_file_encoding=None, required_fields=None, **overrides)`. Order: "Explicit keyword overrides", then "A `.env` file (when *env_file_path* is explicitly provided)", then "Environment variables (``)", then defaults. `SecretString`: "`str()`, `repr()`, formatting, and concatenation display '**********'". "Use `get_secret_value()` when passing a credential to an SDK". | +| Core `exceptions.py` | https://github.com/microsoft/agent-framework/blob/main/python/packages/core/agent_framework/exceptions.py | βœ… (grep) | `ToolException(AgentFrameworkException)`, `ToolExecutionException(ToolException)`, `UserInputRequiredException(ToolException)`. | +| Core vendor shims | https://github.com/microsoft/agent-framework/blob/main/python/packages/core/agent_framework/mem0/__init__.py, `…/tools/__init__.py` | βœ… | `IMPORT_PATH = "agent_framework_mem0"`, `PACKAGE_NAME = "agent-framework-mem0"`, and `__getattr__` lazily imports the separate top-level module. So the `agent_framework.` path exists only when core ships a shim. The core package dir contains `__init__.py`, so it is a regular package, not a namespace package. | +| In-repo `pyproject.toml`s | e.g. https://github.com/microsoft/agent-framework/blob/main/python/packages/tools/pyproject.toml | βœ… | core 1.26.0 `requires-python >=3.11`, MIT, "Production/Stable", deps msgspec, pydantic, python-dotenv, opentelemetry-api, pyyaml, regex. `agent-framework-tools` 1.0.0b261112 depends on `agent-framework-core>=1.19.0,<2`. **Every package checked** (core, tools, mem0, typesafe, nvidia, oracle, mongodb, cohere, mistral, monty) has `authors = [{ name = "Microsoft", email = "af-support@microsoft.com" }]`. Commit authors on typesafe, nvidia, oracle, and mongodb include non-Microsoft-looking logins (e.g. `Prognosticate-X`, `manjunathshiva`, `ZedingZhang`), so vendors contribute code but Microsoft publishes it. | +| Samples | https://github.com/microsoft/agent-framework/blob/main/python/samples/01-get-started/02_add_tools.py, `02-agents/tools/README.md`, `02-agents/tools/tool_in_class.py` | βœ… | `@tool(approval_mode="never_require")` plus `Agent(client=FoundryChatClient(...), instructions=..., tools=[get_weather])`. Per-run `agent.run(query, tools=[...])`. Bound methods passed directly as tools. The README lists approvals, max invocations, `FunctionInvocationContext` with `ctx.add_tools`, and the warning about JSON schema mappings. | +| Python community catalog | https://github.com/microsoft/agent-framework/blob/main/python/samples/community-projects.md | βœ… | Sections: Context providers (Bhived, DXMT, Membase, MemorySync, OpenViking, Supermemory) and Middleware (ACGS, BotsRated, Donkey Development Kit, Tracekit). **No Tools section** after PR #10517 (2026-12-03) removed Engram for a broken link. | +| Catalog review skill | https://github.com/microsoft/agent-framework/blob/main/.github/skills/community-projects/SKILL.md | βœ… (146 lines) | Components: "`Model providers`, `Agent services`, `Tools`, `Context providers`, `Vector stores`, `Middleware`, `Evaluation`, or `UI`". Columns: "`Name`, `Brief description`, `Scenarios`, `Project`, `Issues`". Eligibility: published and reader-facing; `Issues` URL "ending in `/issues/new` or `/issues/new/choose`"; neutral wording. Exclusions include "Services that only expose an OpenAI-compatible endpoint", "MCP servers or gateways that only require Agent Framework's standard MCP client or tool configuration", "Official Microsoft-owned integrations", "Unpublished, planned, proposed", and "Projects that direct support or issue reports to a Microsoft repository". "The Agent Framework team syncs these source catalogs to the Microsoft Learn documentation repository." | +| Catalog PRs | https://github.com/microsoft/agent-framework/pull/10032, /10160, /10270, /10517 | βœ… (API) | #10032 Bhived (vendor author: "I build bhived"), #10160 DXMT, and #10270 Supermemory were each merged within minutes of opening as direct one-row PRs, with no issue linked in the bodies read. #10517 removed the Engram Tools row. | +| Learn: Tools Overview | https://learn.microsoft.com/en-us/agent-framework/agents/tools/ | βœ… (ms.date 2026-10-22, updated 2026-11-17) | Python tool types: Function Tools, Code Interpreter, File Search, Web Search, Hosted MCP, Local MCP, Foundry Toolbox, Shell tools, Image Generation, computer use, Bing Grounding (experimental), Bing Custom Search (preview), Foundry IQ (experimental), and others. Python matrix: Web Search βœ… Responses, Chat Completion, Foundry, Anthropic; ❌ Ollama, Foundry Local, GitHub Copilot. Function tools βœ… everywhere (⚠️ local models depend on model support). Warning: "Tool calls and arguments are generated by the model. Validate and authorize them before application code performs side effects." .NET: `AIFunctionFactory.Create(GetWeather)` and `.AsAIFunction()`. Mentions a Go SDK (`microsoft/agent-framework-go`). | +| Learn: Integrations | https://learn.microsoft.com/en-us/agent-framework/integrations/ | βœ… (ms.date 2026-10-23) | Browse by provider (Microsoft Foundry, Azure, OpenAI, Anthropic, AWS, Google, Ollama, Mistral, TypeSafe AI) and by component. "Community-maintained integrations are listed separately from Microsoft-owned guidance." | +| Learn: Tool integrations | https://learn.microsoft.com/en-us/agent-framework/integrations/by-component/tools/ | βœ… (ms.date 2026-07-29) | Only Microsoft Foundry Toolbox and Shell tools. | +| Learn: Community projects | https://learn.microsoft.com/en-us/agent-framework/integrations/community-projects | βœ… (ms.date 2026-11-27) | "To request inclusion, open a pull request against the Python catalog in the Agent Framework repository." The Python pivot still showed a **Tools** row (Engram) at the time of fetch, which is out of sync with the repo (removed 2026-12-03). The .NET pivot lists only vector stores (`CommunityToolkit.VectorData.*`, `CouchbaseConnector.SemanticKernel`, `Elastic.SemanticKernel.Connectors.Elasticsearch`). The Go pivot is empty. | +| PyPI simple index | https://pypi.org/simple/ (JSON, ~47 MB) | βœ… | 92 names match `^agent[-_.]?framework`. Diffbot-related names: `collective.diffbot`, `diffbot`, `diffbot-enhance-client`, `diffbot-kg`, `diffbot-mcp`, `diffbot-nlapi`, `diffbot-python`, `langchain-diffbot`, `pydiffbot`, `spacy-diffbot-nlapi`, and others. **`agent-framework-diffbot` and `diffbot-agent-framework` are not registered.** | +| PyPI JSON (~20 names) | https://pypi.org/pypi//json | βœ… | Microsoft (`af-support@microsoft.com`): agent-framework, -core, -mem0, -neo4j (0.5.4). **Microsoft placeholders, all `0.0.0a1` uploaded 2025-09-30:** -weaviate, -pinecone, -community, -astradb, -chroma, -milvus, -google, -aws, -mongodb-atlas. **Vendor-published:** -goodmem 0.2.0 (GoodMem, `support@goodmem.ai`), -mnemoverse 0.1.0 (Mnemoverse), -membase 0.2.1 (Membase), -recallic 0.1.2 (Recallic), -agent-commerce 0.1.1, -botsrated 0.1.6, -plimsoll 0.32.0. All seven were first uploaded between 2026-05 and 2026-11. | +| Vendor wheels (listing + METADATA + grep) | e.g. https://pypi.org/project/agent-framework-recallic/ | βœ… | Every vendor wheel ships a top-level `agent_framework_/` module. None writes into `agent_framework/`. Requires `agent-framework-core` (e.g. `<2,>=1.26`), not the meta package. Patterns: recallic `def tools(self, user_id=None) -> list[FunctionTool]`; mnemoverse `@tool(name="mnemoverse_save", approval_mode="never_require")`, returns `list[FunctionTool]`, with a `MNEMOVERSE_API_KEY` env fallback; agent-commerce `async def agent_commerce_tools(**kwargs) -> list[FunctionTool]`. Licences: MIT or Apache-2.0. | +| PEP 752 | https://peps.python.org/pep-0752/ | βœ… | "Implicit namespaces for package repositories", **Accepted**, resolution 29-Jun-2026. It would let organizations reserve a prefix so only the owner can upload matching projects. The page doesn't confirm deployment on PyPI, and the PyPI policy lives in PEP 755 (a proposal). Effect on existing non-owner projects: **not verified** (open question 1b). | +| NuGet search | https://azuresearch-usnc.nuget.org/query?q=Microsoft.Agents.AI&prerelease=true | βœ… | `Microsoft.Agents.AI` 1.28.0, `.Abstractions`, `.Workflows`, `.OpenAI`, `.Foundry` 1.5.0, `.Anthropic`, `.Harness`, `.GitHub.Copilot`, `.Declarative`, `.Purview`, `.DurableTask`, and others. Owners `['Microsoft', 'MicrosoftAgentFramework']`, `verified: True`. Third-party examples: `DeepSeek.Agents.AI` (owner `yueyuan`, not verified), `CommunityToolkit.VectorData.*`. | +| `dotnet/src` listing | https://github.com/microsoft/agent-framework/tree/main/dotnet/src | βœ… | Includes `Microsoft.Agents.AI.Mcp`, `.Mem0`, `.Tools.Shell`, `.Valkey`, `.Hyperlight`, `.CosmosNoSql`, and others. All are `Microsoft.Agents.AI.*`. | +| NuGet ID prefix reservation | https://learn.microsoft.com/en-us/nuget/nuget-org/id-prefix-reservation | βœ… | "Whenever a package is submitted to nuget.org with an ID that matches the reserved ID prefix, the package is rejected unless it originates from the owner(s) that reserved the ID prefix." Example: "'Microsoft' owns 'Microsoft.\*'". To apply, mail `account@nuget.org`. | +| `diffbot/diffbot-mcp` README | https://github.com/diffbot/diffbot-mcp | βœ… | Hosted at `https://mcp.diffbot.com/mcp` (one-click sign-in) or local `uvx diffbot-mcp`. Tools: extract, search_web, crawl, resolve_entities, search_news, search_organizations, search_people, search_places, search_deals, dql, dql_probe, dql_ontology. | +| Diffbot org repos | https://github.com/orgs/diffbot/repositories | βœ… (API) | No `agent-framework-diffbot` or MAF repo. `diffbot-csharp-client` exists (legacy, not evaluated). | +| `AI_CONTRIBUTIONS.md` | https://github.com/microsoft/agent-framework/blob/main/AI_CONTRIBUTIONS.md | ❌ not opened | Only relevant if we ever PR code upstream. | +| ADR-0008 (Python subpackages) | https://github.com/microsoft/agent-framework/blob/main/docs/decisions/0008-python-subpackages.md | ❌ not opened | The design doc summarises it. | +| Learn: Function tools page | https://learn.microsoft.com/en-us/agent-framework/agents/tools/function-tools | ❌ not opened | Repo samples and `_tools.py` docstrings cover the API. | + +## 2. Diffbot SDK facts (this checkout, `diffbot` 3.4.1) + +- `pyproject.toml`: `name = "diffbot"`, `version = "3.4.1"`, `requires-python = ">=3.9"`, deps `httpx>=0.27.0`, `click>=8.1.0`, `rich>=13.0.0`. +- `DiffbotAsync.__init__(self, token, *, timeout, retry, api_base, kg_base, llm_base, nlp_base, analyze_url, llm_url, crawler_url, web_search_url, nlp_url, dql_url, ontology_url, transport)` does `if not token: raise ValidationError("token is required")`. It does not call `resolve_token()`. `transport: httpx.AsyncBaseTransport` allows `httpx.MockTransport` in tests. +- Async methods: `close`, `request`, `extract` (default `api="analyze"`, `fmt="markdown"`), `ask` (an `AsyncIterator[str]`), `ask_json(messages, schema=None, *, response_format=None)`, `crawl`, `crawl_*`, `dql`, `dql_parallel`, `dql_fetch_ontology`, `dql_fetch_ontology_text`, `dql_refresh_ontology`, `web_search(text, *, num_results, max_tokens, snippet_length)`, `account`, `verify_token`, `entities`, `nlp`. +- `resolve_token()` (in `_auth.py`) checks the explicit argument, then `DIFFBOT_API_TOKEN`, then `~/.diffbot/credentials`. It is used by the CLI only. The integration must not use it. +- User-Agent is hard-coded: `{"User-Agent": f"diffbot-python/{__version__}"}`. +- No Enhance wrapper and no structured DQL builders. Neither is needed for v0.1. + +## 3. Discrepancies against the task's starting notes + +- The task says to "pass as tools to `agent_framework.Agent` (or the current API)". Confirmed: `Agent` is current. `ChatAgent` was renamed (#3747). +- The task suggests official connectors import as `agent_framework.` or `agent_framework_`. Both exist for **Microsoft** packages: the real module is `agent_framework_`, and `agent_framework.` is a lazy shim in core. Vendor packages only get `agent_framework_`. +- The task asks whether the `agent-framework-*` prefix is reserved. On PyPI, no enforcement was observed: vendors publish under it, and Microsoft defensively placeholder-registered some names. PEP 752 could change this (unverified). On NuGet, `Microsoft.*` is reserved. +- The task lists "Samples / docs-only contribution" as a possible first public step. The repo's sanctioned path for vendors is the **community catalog**, not samples. + +## 4. Things not verified (carry into M1) + +- Whether `load_settings` and `SecretString` are intended for use by external packages. They are root exports in a `released` package, so they are covered by the API-compat check, but no doc addresses third parties. +- How a raised `ToolExecutionException` is surfaced to the model versus an error string (see `function_tool_recover_from_failures.py`, not opened). +- The exact public accessor for a `FunctionTool`'s JSON schema, for test assertions. +- Whether core ships a reusable mock chat client for offline agent-loop tests. +- Whether the Diffbot LLM endpoint works as a model through `OpenAIChatCompletionClient` with a custom base URL. Not needed for v0.1. +- PEP 752 deployment status on PyPI, and its effect on existing third-party `agent-framework-*` names. +- Whether `diffbot/diffbot-csharp-client` is usable for a .NET phase. + +## 5. Decisions log + +| Date | Decision | Source | +| --- | --- | --- | +| 2026-12-02 | Org/Person Enhance deferred from v0.1. 7 operations. | Andrew (carried over from the n8n and Langflow plans). | +| β€” | Package name, licence, .NET timing, catalog PR | Open (plan Β§8). |