deepagents-okf-backend 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- deepagents_okf_backend-0.1.0/.github/ISSUE_TEMPLATE/bug_report.yml +26 -0
- deepagents_okf_backend-0.1.0/.github/ISSUE_TEMPLATE/config.yml +8 -0
- deepagents_okf_backend-0.1.0/.github/ISSUE_TEMPLATE/feature_request.yml +18 -0
- deepagents_okf_backend-0.1.0/.github/PULL_REQUEST_TEMPLATE.md +11 -0
- deepagents_okf_backend-0.1.0/.github/dependabot.yml +13 -0
- deepagents_okf_backend-0.1.0/.github/workflows/ci.yml +29 -0
- deepagents_okf_backend-0.1.0/.github/workflows/release.yml +26 -0
- deepagents_okf_backend-0.1.0/.gitignore +25 -0
- deepagents_okf_backend-0.1.0/CODE_OF_CONDUCT.md +56 -0
- deepagents_okf_backend-0.1.0/CONTRIBUTING.md +35 -0
- deepagents_okf_backend-0.1.0/LICENSE +21 -0
- deepagents_okf_backend-0.1.0/PKG-INFO +168 -0
- deepagents_okf_backend-0.1.0/README.md +132 -0
- deepagents_okf_backend-0.1.0/SECURITY.md +25 -0
- deepagents_okf_backend-0.1.0/examples/composite_knowledge.py +36 -0
- deepagents_okf_backend-0.1.0/examples/quickstart.py +39 -0
- deepagents_okf_backend-0.1.0/examples/real_agent.py +95 -0
- deepagents_okf_backend-0.1.0/pyproject.toml +67 -0
- deepagents_okf_backend-0.1.0/src/deepagents_okf_backend/__init__.py +22 -0
- deepagents_okf_backend-0.1.0/src/deepagents_okf_backend/backend.py +376 -0
- deepagents_okf_backend-0.1.0/src/deepagents_okf_backend/frontmatter.py +57 -0
- deepagents_okf_backend-0.1.0/src/deepagents_okf_backend/okf.py +64 -0
- deepagents_okf_backend-0.1.0/src/deepagents_okf_backend/py.typed +0 -0
- deepagents_okf_backend-0.1.0/src/deepagents_okf_backend/query.py +127 -0
- deepagents_okf_backend-0.1.0/tests/fixtures/sample_bundle/index.md +10 -0
- deepagents_okf_backend-0.1.0/tests/fixtures/sample_bundle/metrics/weekly_active_users.md +9 -0
- deepagents_okf_backend-0.1.0/tests/fixtures/sample_bundle/tables/orders.md +17 -0
- deepagents_okf_backend-0.1.0/tests/test_backend_async.py +28 -0
- deepagents_okf_backend-0.1.0/tests/test_backend_binary.py +37 -0
- deepagents_okf_backend-0.1.0/tests/test_backend_io.py +86 -0
- deepagents_okf_backend-0.1.0/tests/test_frontmatter.py +51 -0
- deepagents_okf_backend-0.1.0/tests/test_okf.py +29 -0
- deepagents_okf_backend-0.1.0/tests/test_query.py +53 -0
- deepagents_okf_backend-0.1.0/tests/test_robustness.py +65 -0
- deepagents_okf_backend-0.1.0/tests/test_security.py +50 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: Bug report
|
|
2
|
+
description: Report a problem with deepagents-okf-backend
|
|
3
|
+
labels: ["bug"]
|
|
4
|
+
body:
|
|
5
|
+
- type: textarea
|
|
6
|
+
id: what-happened
|
|
7
|
+
attributes:
|
|
8
|
+
label: What happened?
|
|
9
|
+
description: A clear description of the bug and what you expected instead.
|
|
10
|
+
validations:
|
|
11
|
+
required: true
|
|
12
|
+
- type: textarea
|
|
13
|
+
id: repro
|
|
14
|
+
attributes:
|
|
15
|
+
label: Minimal reproduction
|
|
16
|
+
description: Smallest code snippet that reproduces the issue.
|
|
17
|
+
render: python
|
|
18
|
+
validations:
|
|
19
|
+
required: true
|
|
20
|
+
- type: input
|
|
21
|
+
id: versions
|
|
22
|
+
attributes:
|
|
23
|
+
label: Versions
|
|
24
|
+
description: Output of `pip show deepagents-okf-backend deepagents | grep Version` and your Python version.
|
|
25
|
+
validations:
|
|
26
|
+
required: true
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
blank_issues_enabled: false
|
|
2
|
+
contact_links:
|
|
3
|
+
- name: Deep Agents docs
|
|
4
|
+
url: https://docs.langchain.com/oss/python/deepagents/backends
|
|
5
|
+
about: How backends work in LangChain Deep Agents.
|
|
6
|
+
- name: Open Knowledge Format (OKF)
|
|
7
|
+
url: https://cloud.google.com/blog/products/data-analytics/how-the-open-knowledge-format-can-improve-data-sharing
|
|
8
|
+
about: The OKF specification this backend targets.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
name: Feature request
|
|
2
|
+
description: Suggest an idea for deepagents-okf-backend
|
|
3
|
+
labels: ["enhancement"]
|
|
4
|
+
body:
|
|
5
|
+
- type: textarea
|
|
6
|
+
id: problem
|
|
7
|
+
attributes:
|
|
8
|
+
label: Problem
|
|
9
|
+
description: What are you trying to do that is hard or impossible today?
|
|
10
|
+
validations:
|
|
11
|
+
required: true
|
|
12
|
+
- type: textarea
|
|
13
|
+
id: proposal
|
|
14
|
+
attributes:
|
|
15
|
+
label: Proposed solution
|
|
16
|
+
description: How could the backend or OKF integration solve it?
|
|
17
|
+
validations:
|
|
18
|
+
required: true
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
## Summary
|
|
2
|
+
|
|
3
|
+
<!-- What does this PR change and why? -->
|
|
4
|
+
|
|
5
|
+
## Checklist
|
|
6
|
+
|
|
7
|
+
- [ ] `ruff check .` passes
|
|
8
|
+
- [ ] `mypy src` passes
|
|
9
|
+
- [ ] `pytest` passes (added/updated tests for the change)
|
|
10
|
+
- [ ] Backend methods still return result types with `error` set — they never raise
|
|
11
|
+
- [ ] Updated `CHANGELOG.md` if user-facing
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
fail-fast: false
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- uses: actions/setup-python@v5
|
|
18
|
+
with:
|
|
19
|
+
python-version: ${{ matrix.python-version }}
|
|
20
|
+
- name: Install
|
|
21
|
+
run: |
|
|
22
|
+
python -m pip install --upgrade pip
|
|
23
|
+
pip install -e ".[dev]"
|
|
24
|
+
- name: Lint
|
|
25
|
+
run: ruff check .
|
|
26
|
+
- name: Type check
|
|
27
|
+
run: mypy src
|
|
28
|
+
- name: Test
|
|
29
|
+
run: pytest -q --cov=deepagents_okf_backend --cov-report=term-missing --cov-fail-under=85
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: ["v*"]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build-and-publish:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
environment: pypi
|
|
14
|
+
permissions:
|
|
15
|
+
id-token: write # PyPI Trusted Publishing (OIDC), no API token needed
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
- uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: "3.12"
|
|
21
|
+
- name: Build
|
|
22
|
+
run: |
|
|
23
|
+
python -m pip install --upgrade pip build
|
|
24
|
+
python -m build
|
|
25
|
+
- name: Publish to PyPI
|
|
26
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
.eggs/
|
|
6
|
+
build/
|
|
7
|
+
dist/
|
|
8
|
+
.venv/
|
|
9
|
+
venv/
|
|
10
|
+
|
|
11
|
+
# Tooling
|
|
12
|
+
.pytest_cache/
|
|
13
|
+
.mypy_cache/
|
|
14
|
+
.ruff_cache/
|
|
15
|
+
.coverage
|
|
16
|
+
htmlcov/
|
|
17
|
+
|
|
18
|
+
# Editors / OS
|
|
19
|
+
.idea/
|
|
20
|
+
.vscode/
|
|
21
|
+
.DS_Store
|
|
22
|
+
|
|
23
|
+
# Internal working docs — kept local, not published
|
|
24
|
+
/DEVELOPMENT_PLAN.md
|
|
25
|
+
/CHANGELOG.md
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
+
diverse, inclusive, and healthy community.
|
|
14
|
+
|
|
15
|
+
## Our Standards
|
|
16
|
+
|
|
17
|
+
Examples of behavior that contributes to a positive environment include:
|
|
18
|
+
|
|
19
|
+
- Demonstrating empathy and kindness toward other people
|
|
20
|
+
- Being respectful of differing opinions, viewpoints, and experiences
|
|
21
|
+
- Giving and gracefully accepting constructive feedback
|
|
22
|
+
- Accepting responsibility and apologizing to those affected by our mistakes
|
|
23
|
+
- Focusing on what is best for the overall community
|
|
24
|
+
|
|
25
|
+
Examples of unacceptable behavior include:
|
|
26
|
+
|
|
27
|
+
- The use of sexualized language or imagery, and sexual attention or advances
|
|
28
|
+
- Trolling, insulting or derogatory comments, and personal or political attacks
|
|
29
|
+
- Public or private harassment
|
|
30
|
+
- Publishing others' private information without explicit permission
|
|
31
|
+
- Other conduct which could reasonably be considered inappropriate
|
|
32
|
+
|
|
33
|
+
## Enforcement Responsibilities
|
|
34
|
+
|
|
35
|
+
Community leaders are responsible for clarifying and enforcing our standards and
|
|
36
|
+
will take appropriate and fair corrective action in response to any behavior
|
|
37
|
+
that they deem inappropriate, threatening, offensive, or harmful.
|
|
38
|
+
|
|
39
|
+
## Scope
|
|
40
|
+
|
|
41
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
42
|
+
an individual is officially representing the community in public spaces.
|
|
43
|
+
|
|
44
|
+
## Enforcement
|
|
45
|
+
|
|
46
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
47
|
+
reported to the maintainers at **emanueleielo@gmail.com**. All complaints will
|
|
48
|
+
be reviewed and investigated promptly and fairly.
|
|
49
|
+
|
|
50
|
+
## Attribution
|
|
51
|
+
|
|
52
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
53
|
+
version 2.1, available at
|
|
54
|
+
https://www.contributor-covenant.org/version/2/1/code_of_conduct.html.
|
|
55
|
+
|
|
56
|
+
[homepage]: https://www.contributor-covenant.org
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for helping improve `deepagents-okf-backend`!
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
python -m venv .venv && source .venv/bin/activate
|
|
9
|
+
pip install -e ".[dev]"
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Checks (must pass before a PR)
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
ruff check .
|
|
16
|
+
mypy src
|
|
17
|
+
pytest
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Guidelines
|
|
21
|
+
|
|
22
|
+
- **Never raise from backend methods.** Return the appropriate result type with `error` set
|
|
23
|
+
(this is the `BackendProtocol` contract).
|
|
24
|
+
- Keep `frontmatter.py` and `okf.py` free of `deepagents` imports — they are pure helpers and
|
|
25
|
+
the bulk of the test coverage lives there.
|
|
26
|
+
- Add/extend tests under `tests/` for any behavior change; keep the sample bundle in
|
|
27
|
+
`tests/fixtures/sample_bundle/` a **valid** OKF bundle.
|
|
28
|
+
- Match the existing code style; imports go at the top of the file.
|
|
29
|
+
|
|
30
|
+
## Releasing
|
|
31
|
+
|
|
32
|
+
1. Bump `version` in `pyproject.toml` and update `CHANGELOG.md`.
|
|
33
|
+
2. Tag `vX.Y.Z`, push, let CI build.
|
|
34
|
+
3. Publish to PyPI, create a GitHub release.
|
|
35
|
+
4. Open a PR to the LangChain docs repo adding a row to the `integrations/backends` table.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Emanuele Ielo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: deepagents-okf-backend
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: OKF-aware virtual filesystem backend for LangChain Deep Agents (Open Knowledge Format).
|
|
5
|
+
Project-URL: Homepage, https://github.com/emanueleielo/deepagents-okf-backend
|
|
6
|
+
Project-URL: Repository, https://github.com/emanueleielo/deepagents-okf-backend
|
|
7
|
+
Project-URL: Issues, https://github.com/emanueleielo/deepagents-okf-backend/issues
|
|
8
|
+
Project-URL: OKF spec, https://cloud.google.com/blog/products/data-analytics/how-the-open-knowledge-format-can-improve-data-sharing
|
|
9
|
+
Author-email: Emanuele Ielo <emanueleielo@gmail.com>
|
|
10
|
+
License: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: agent,backend,deepagents,langchain,llm,okf,open-knowledge-format
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Requires-Dist: deepagents>=0.6
|
|
23
|
+
Requires-Dist: langchain-core>=0.3
|
|
24
|
+
Requires-Dist: pyyaml>=6.0
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
31
|
+
Requires-Dist: types-pyyaml>=6.0; extra == 'dev'
|
|
32
|
+
Provides-Extra: examples
|
|
33
|
+
Requires-Dist: langchain-anthropic>=0.3; extra == 'examples'
|
|
34
|
+
Requires-Dist: python-dotenv>=1.0; extra == 'examples'
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
|
|
37
|
+
# deepagents-okf-backend
|
|
38
|
+
|
|
39
|
+
[](https://github.com/emanueleielo/deepagents-okf-backend/actions/workflows/ci.yml)
|
|
40
|
+
[](https://pypi.org/project/deepagents-okf-backend/)
|
|
41
|
+
[](https://pypi.org/project/deepagents-okf-backend/)
|
|
42
|
+
[](LICENSE)
|
|
43
|
+
[](https://github.com/astral-sh/ruff)
|
|
44
|
+
|
|
45
|
+
An **OKF-aware virtual filesystem backend** for [LangChain Deep Agents](https://docs.langchain.com/oss/python/deepagents/overview).
|
|
46
|
+
|
|
47
|
+
It mounts an [Open Knowledge Format (OKF)](https://cloud.google.com/blog/products/data-analytics/how-the-open-knowledge-format-can-improve-data-sharing)
|
|
48
|
+
bundle — *"a directory of markdown files with YAML frontmatter"* — as the agent's filesystem,
|
|
49
|
+
so a deep agent can **read, search, and curate** organizational knowledge while every write
|
|
50
|
+
stays a **valid OKF document**.
|
|
51
|
+
|
|
52
|
+
> 🧩 Community backend (not maintained by LangChain), built for the
|
|
53
|
+
> [`integrations/backends`](https://docs.langchain.com/oss/python/integrations/backends) list.
|
|
54
|
+
|
|
55
|
+
## Why
|
|
56
|
+
|
|
57
|
+
A deep agent's knowledge memory is usually either **ephemeral** (`StateBackend`) or **closed**
|
|
58
|
+
(`ContextHubBackend` → LangSmith Hub). OKF is the **open, vendor-neutral** alternative:
|
|
59
|
+
git-versionable markdown, human-readable, parseable by any agent or framework.
|
|
60
|
+
|
|
61
|
+
| | `StateBackend` | `StoreBackend` | `FilesystemBackend` | **`OKFBackend`** |
|
|
62
|
+
|---|---|---|---|---|
|
|
63
|
+
| Persists across threads | ❌ | ✅ | ✅ | ✅ |
|
|
64
|
+
| Human-readable on disk | ❌ | ❌ | ✅ | ✅ |
|
|
65
|
+
| Vendor-neutral / portable bundle | ❌ | ❌ | ➖ | ✅ |
|
|
66
|
+
| Structured frontmatter query | ❌ | ❌ | ❌ | ✅ |
|
|
67
|
+
| Validates writes as a shareable format | ❌ | ❌ | ❌ | ✅ |
|
|
68
|
+
|
|
69
|
+
What `OKFBackend` adds:
|
|
70
|
+
|
|
71
|
+
- **Open knowledge, no lock-in** — portable markdown bundles, not a proprietary store.
|
|
72
|
+
- **Semantic, not blind** — query by `type` / `tags` / `title`, not just `grep`.
|
|
73
|
+
- **Self-improving wiki** — the agent maintains the bundle; writes are validated as OKF.
|
|
74
|
+
- **Cross-agent sharing** — *"a bundle synthesized by one LLM can be queried by another."*
|
|
75
|
+
- **Sync + async**, path-sandboxed to the bundle root, fully typed (`py.typed`).
|
|
76
|
+
|
|
77
|
+
## Install
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
pip install deepagents-okf-backend
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Quickstart
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
from deepagents import create_deep_agent
|
|
87
|
+
from deepagents_okf_backend import OKFBackend
|
|
88
|
+
|
|
89
|
+
backend = OKFBackend("./knowledge", validate=True, auto_timestamp=True)
|
|
90
|
+
|
|
91
|
+
agent = create_deep_agent(
|
|
92
|
+
tools=[],
|
|
93
|
+
instructions="You curate the organization's OKF knowledge bundle.",
|
|
94
|
+
backend=backend,
|
|
95
|
+
)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Knowledge surface + scratch space (`CompositeBackend`)
|
|
99
|
+
|
|
100
|
+
Mount the OKF bundle on `/knowledge` and keep an ephemeral scratch filesystem on `/`:
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from deepagents.backends import CompositeBackend, StateBackend
|
|
104
|
+
from deepagents_okf_backend import OKFBackend
|
|
105
|
+
|
|
106
|
+
backend = CompositeBackend(
|
|
107
|
+
routes={"/knowledge": OKFBackend("./knowledge")},
|
|
108
|
+
default=StateBackend(),
|
|
109
|
+
)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Structured query tool
|
|
113
|
+
|
|
114
|
+
The six standard filesystem tools only `grep` raw text. Give the agent a typed lookup over
|
|
115
|
+
OKF frontmatter:
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
from deepagents import create_deep_agent
|
|
119
|
+
from deepagents_okf_backend import OKFBackend, make_okf_query_tool
|
|
120
|
+
|
|
121
|
+
backend = OKFBackend("./knowledge")
|
|
122
|
+
agent = create_deep_agent(
|
|
123
|
+
tools=[make_okf_query_tool(backend)], # okf_query(type=..., tags=..., title_contains=...)
|
|
124
|
+
instructions="Use okf_query to find tables and metrics before answering.",
|
|
125
|
+
backend=backend,
|
|
126
|
+
)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
You can also call it directly:
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
from deepagents_okf_backend import query_bundle
|
|
133
|
+
|
|
134
|
+
hits = query_bundle(backend, type="Metric", tags=["growth"])
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## What is OKF?
|
|
138
|
+
|
|
139
|
+
Open Knowledge Format (Google Cloud, 2026) represents knowledge as a directory of markdown
|
|
140
|
+
files with YAML frontmatter. The only required field is `type`; `title`, `description`,
|
|
141
|
+
`resource`, `tags`, and `timestamp` are optional. See the
|
|
142
|
+
[announcement](https://cloud.google.com/blog/products/data-analytics/how-the-open-knowledge-format-can-improve-data-sharing).
|
|
143
|
+
|
|
144
|
+
```markdown
|
|
145
|
+
---
|
|
146
|
+
type: BigQuery Table
|
|
147
|
+
title: Orders
|
|
148
|
+
description: One row per completed customer order.
|
|
149
|
+
tags: [sales, revenue]
|
|
150
|
+
---
|
|
151
|
+
# Schema
|
|
152
|
+
| Column | Type | Description |
|
|
153
|
+
|--------|------|-------------|
|
|
154
|
+
| `order_id` | STRING | Globally unique order identifier. |
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Development
|
|
158
|
+
|
|
159
|
+
See [`DEVELOPMENT_PLAN.md`](DEVELOPMENT_PLAN.md). Contributions welcome — see [`CONTRIBUTING.md`](CONTRIBUTING.md).
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
pip install -e ".[dev]"
|
|
163
|
+
ruff check . && mypy src && pytest --cov=deepagents_okf_backend
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## License
|
|
167
|
+
|
|
168
|
+
MIT © Emanuele Ielo
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# deepagents-okf-backend
|
|
2
|
+
|
|
3
|
+
[](https://github.com/emanueleielo/deepagents-okf-backend/actions/workflows/ci.yml)
|
|
4
|
+
[](https://pypi.org/project/deepagents-okf-backend/)
|
|
5
|
+
[](https://pypi.org/project/deepagents-okf-backend/)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](https://github.com/astral-sh/ruff)
|
|
8
|
+
|
|
9
|
+
An **OKF-aware virtual filesystem backend** for [LangChain Deep Agents](https://docs.langchain.com/oss/python/deepagents/overview).
|
|
10
|
+
|
|
11
|
+
It mounts an [Open Knowledge Format (OKF)](https://cloud.google.com/blog/products/data-analytics/how-the-open-knowledge-format-can-improve-data-sharing)
|
|
12
|
+
bundle — *"a directory of markdown files with YAML frontmatter"* — as the agent's filesystem,
|
|
13
|
+
so a deep agent can **read, search, and curate** organizational knowledge while every write
|
|
14
|
+
stays a **valid OKF document**.
|
|
15
|
+
|
|
16
|
+
> 🧩 Community backend (not maintained by LangChain), built for the
|
|
17
|
+
> [`integrations/backends`](https://docs.langchain.com/oss/python/integrations/backends) list.
|
|
18
|
+
|
|
19
|
+
## Why
|
|
20
|
+
|
|
21
|
+
A deep agent's knowledge memory is usually either **ephemeral** (`StateBackend`) or **closed**
|
|
22
|
+
(`ContextHubBackend` → LangSmith Hub). OKF is the **open, vendor-neutral** alternative:
|
|
23
|
+
git-versionable markdown, human-readable, parseable by any agent or framework.
|
|
24
|
+
|
|
25
|
+
| | `StateBackend` | `StoreBackend` | `FilesystemBackend` | **`OKFBackend`** |
|
|
26
|
+
|---|---|---|---|---|
|
|
27
|
+
| Persists across threads | ❌ | ✅ | ✅ | ✅ |
|
|
28
|
+
| Human-readable on disk | ❌ | ❌ | ✅ | ✅ |
|
|
29
|
+
| Vendor-neutral / portable bundle | ❌ | ❌ | ➖ | ✅ |
|
|
30
|
+
| Structured frontmatter query | ❌ | ❌ | ❌ | ✅ |
|
|
31
|
+
| Validates writes as a shareable format | ❌ | ❌ | ❌ | ✅ |
|
|
32
|
+
|
|
33
|
+
What `OKFBackend` adds:
|
|
34
|
+
|
|
35
|
+
- **Open knowledge, no lock-in** — portable markdown bundles, not a proprietary store.
|
|
36
|
+
- **Semantic, not blind** — query by `type` / `tags` / `title`, not just `grep`.
|
|
37
|
+
- **Self-improving wiki** — the agent maintains the bundle; writes are validated as OKF.
|
|
38
|
+
- **Cross-agent sharing** — *"a bundle synthesized by one LLM can be queried by another."*
|
|
39
|
+
- **Sync + async**, path-sandboxed to the bundle root, fully typed (`py.typed`).
|
|
40
|
+
|
|
41
|
+
## Install
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pip install deepagents-okf-backend
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Quickstart
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from deepagents import create_deep_agent
|
|
51
|
+
from deepagents_okf_backend import OKFBackend
|
|
52
|
+
|
|
53
|
+
backend = OKFBackend("./knowledge", validate=True, auto_timestamp=True)
|
|
54
|
+
|
|
55
|
+
agent = create_deep_agent(
|
|
56
|
+
tools=[],
|
|
57
|
+
instructions="You curate the organization's OKF knowledge bundle.",
|
|
58
|
+
backend=backend,
|
|
59
|
+
)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Knowledge surface + scratch space (`CompositeBackend`)
|
|
63
|
+
|
|
64
|
+
Mount the OKF bundle on `/knowledge` and keep an ephemeral scratch filesystem on `/`:
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from deepagents.backends import CompositeBackend, StateBackend
|
|
68
|
+
from deepagents_okf_backend import OKFBackend
|
|
69
|
+
|
|
70
|
+
backend = CompositeBackend(
|
|
71
|
+
routes={"/knowledge": OKFBackend("./knowledge")},
|
|
72
|
+
default=StateBackend(),
|
|
73
|
+
)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Structured query tool
|
|
77
|
+
|
|
78
|
+
The six standard filesystem tools only `grep` raw text. Give the agent a typed lookup over
|
|
79
|
+
OKF frontmatter:
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from deepagents import create_deep_agent
|
|
83
|
+
from deepagents_okf_backend import OKFBackend, make_okf_query_tool
|
|
84
|
+
|
|
85
|
+
backend = OKFBackend("./knowledge")
|
|
86
|
+
agent = create_deep_agent(
|
|
87
|
+
tools=[make_okf_query_tool(backend)], # okf_query(type=..., tags=..., title_contains=...)
|
|
88
|
+
instructions="Use okf_query to find tables and metrics before answering.",
|
|
89
|
+
backend=backend,
|
|
90
|
+
)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
You can also call it directly:
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
from deepagents_okf_backend import query_bundle
|
|
97
|
+
|
|
98
|
+
hits = query_bundle(backend, type="Metric", tags=["growth"])
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## What is OKF?
|
|
102
|
+
|
|
103
|
+
Open Knowledge Format (Google Cloud, 2026) represents knowledge as a directory of markdown
|
|
104
|
+
files with YAML frontmatter. The only required field is `type`; `title`, `description`,
|
|
105
|
+
`resource`, `tags`, and `timestamp` are optional. See the
|
|
106
|
+
[announcement](https://cloud.google.com/blog/products/data-analytics/how-the-open-knowledge-format-can-improve-data-sharing).
|
|
107
|
+
|
|
108
|
+
```markdown
|
|
109
|
+
---
|
|
110
|
+
type: BigQuery Table
|
|
111
|
+
title: Orders
|
|
112
|
+
description: One row per completed customer order.
|
|
113
|
+
tags: [sales, revenue]
|
|
114
|
+
---
|
|
115
|
+
# Schema
|
|
116
|
+
| Column | Type | Description |
|
|
117
|
+
|--------|------|-------------|
|
|
118
|
+
| `order_id` | STRING | Globally unique order identifier. |
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Development
|
|
122
|
+
|
|
123
|
+
See [`DEVELOPMENT_PLAN.md`](DEVELOPMENT_PLAN.md). Contributions welcome — see [`CONTRIBUTING.md`](CONTRIBUTING.md).
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
pip install -e ".[dev]"
|
|
127
|
+
ruff check . && mypy src && pytest --cov=deepagents_okf_backend
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## License
|
|
131
|
+
|
|
132
|
+
MIT © Emanuele Ielo
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
The latest released `0.x` version receives security fixes. This project is
|
|
6
|
+
pre-1.0 and the API may change between minor versions.
|
|
7
|
+
|
|
8
|
+
## Reporting a Vulnerability
|
|
9
|
+
|
|
10
|
+
Please **do not** open a public issue for security problems.
|
|
11
|
+
|
|
12
|
+
Instead, use GitHub's [private vulnerability reporting](https://github.com/emanueleielo/deepagents-okf-backend/security/advisories/new)
|
|
13
|
+
or email **emanueleielo@gmail.com**. You can expect an initial response within a
|
|
14
|
+
few days.
|
|
15
|
+
|
|
16
|
+
## Security notes for this backend
|
|
17
|
+
|
|
18
|
+
`OKFBackend` reads and writes **real files** under the directory you pass as `root`.
|
|
19
|
+
|
|
20
|
+
- The backend sandboxes all agent-supplied paths to `root` (path traversal such as
|
|
21
|
+
`../` is rejected). This is covered by tests.
|
|
22
|
+
- Still, point `root` at a **dedicated bundle directory**, never at a path that
|
|
23
|
+
contains secrets, credentials, or system files. An agent with write access to a
|
|
24
|
+
shared directory can modify anything inside it.
|
|
25
|
+
- For untrusted/hostile workloads prefer an isolated sandbox backend.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""Knowledge surface + scratch space, with a structured OKF query tool.
|
|
2
|
+
|
|
3
|
+
The agent reads/curates an OKF bundle on ``/knowledge`` (durable, validated) while using an
|
|
4
|
+
ephemeral ``StateBackend`` for everything else, and can look documents up by frontmatter.
|
|
5
|
+
|
|
6
|
+
Run: python examples/composite_knowledge.py
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from deepagents import create_deep_agent
|
|
12
|
+
from deepagents.backends import CompositeBackend, StateBackend
|
|
13
|
+
|
|
14
|
+
from deepagents_okf_backend import OKFBackend, make_okf_query_tool
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def build_agent(): # type: ignore[no-untyped-def]
|
|
18
|
+
okf = OKFBackend("./knowledge", validate=True, auto_timestamp=True)
|
|
19
|
+
backend = CompositeBackend(
|
|
20
|
+
routes={"/knowledge": okf},
|
|
21
|
+
default=StateBackend(),
|
|
22
|
+
)
|
|
23
|
+
return create_deep_agent(
|
|
24
|
+
tools=[make_okf_query_tool(okf)],
|
|
25
|
+
instructions=(
|
|
26
|
+
"Knowledge lives under /knowledge as an OKF bundle. "
|
|
27
|
+
"Use okf_query to find tables/metrics before answering, and keep scratch notes "
|
|
28
|
+
"elsewhere."
|
|
29
|
+
),
|
|
30
|
+
backend=backend,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
if __name__ == "__main__":
|
|
35
|
+
agent = build_agent()
|
|
36
|
+
print("Agent ready with OKF knowledge surface on /knowledge")
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""Minimal example: mount an OKF bundle as a deep agent's filesystem.
|
|
2
|
+
|
|
3
|
+
Run: python examples/quickstart.py
|
|
4
|
+
(Requires `pip install deepagents-okf-backend` and a model configured for deepagents.)
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from deepagents_okf_backend import OKFBackend
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def main() -> None:
|
|
13
|
+
backend = OKFBackend("./knowledge", validate=True, auto_timestamp=True)
|
|
14
|
+
|
|
15
|
+
# Write a valid OKF document directly through the backend.
|
|
16
|
+
doc = """---
|
|
17
|
+
type: BigQuery Table
|
|
18
|
+
title: Orders
|
|
19
|
+
description: One row per completed customer order.
|
|
20
|
+
tags: [sales, revenue]
|
|
21
|
+
---
|
|
22
|
+
# Schema
|
|
23
|
+
| Column | Type | Description |
|
|
24
|
+
|--------|------|-------------|
|
|
25
|
+
| `order_id` | STRING | Globally unique order identifier. |
|
|
26
|
+
"""
|
|
27
|
+
result = backend.write("/tables/orders.md", doc)
|
|
28
|
+
print("write ->", result)
|
|
29
|
+
|
|
30
|
+
print("read ->", backend.read("/tables/orders.md").file_data["content"][:60], "...")
|
|
31
|
+
print("grep ->", backend.grep("revenue"))
|
|
32
|
+
|
|
33
|
+
# An invalid OKF doc (no `type`) is rejected without touching disk.
|
|
34
|
+
bad = backend.write("/tables/broken.md", "# no frontmatter here")
|
|
35
|
+
print("invalid write ->", bad.error)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
if __name__ == "__main__":
|
|
39
|
+
main()
|