AI Coding Agent 與記憶系統
OKF Agent Memory 0.2 Binds Architecture Rules to Code Paths, Letting Agents Check Restricted Areas Before Editing
OKF Agent Memory 0.2 uses `code_refs` to link Markdown decision documents to source-code globs, allowing the CLI and MCP to look up `hold`, `constraint`, and `context` rules by file. The new version also blocks path traversal and workspace escape, but whether the rules are actually followed still depends on how the agent is integrated.

OKF Agent Memory 0.2.0 was released on September 12, aiming to solve a common problem for coding agents: knowing a project's rules without knowing which rules apply to which files. Knowledge documents can now include `code_refs` in their YAML frontmatter, using globs to identify constrained modules or files. Before editing, an agent can run `okf search --for-path <file> knowledge` or call `okf_search({"for_path":"<file>"})` through the built-in stdio MCP to retrieve only the decisions relevant to the target path.
Results are ordered by `hold`, `constraint`, and `context`. A `hold` means a file must not be modified without human approval; a `constraint` is a requirement that must be followed when making changes; and `context` provides design background only. When no level is explicitly specified, the tool infers content under `knowledge/convention/` as a constraint and domain and architecture documents as context. This is more traceable than injecting an entire `AGENTS.md` file or rule set into every prompt, and it also lets code reviews directly inspect changes to rules and their path bindings.
The new release also strengthens boundary checks. `ValidateBundle` rejects `code_refs` containing `..` or absolute system paths; `okf validate --drift` verifies the existence of referenced files only within the project root; and MCP bundle resolution is restricted to the canonical workspace root, reducing the risk that an agent could use parameters to probe files outside the workspace. The project claims that in-memory BM25 queries take less than 300 microseconds, but that figure comes from the maintainers' own small knowledge set and cannot be extrapolated to large monorepos. More importantly, these governance labels are still structured instructions supplied to the agent, not filesystem ACLs. Deployers should separately enforce `hold` at the executor or approval layer.