Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions docs/en/docs/integrations/hermes.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,18 @@ Turning off turn capture does not turn off recall, pre-compression capture, or e

| Event/entry | Data sent | Direct recipient | Default/trigger | Disable | Effect when disabled |
| --- | --- | --- | --- | --- | --- |
| Recall / prefetch | Query (trimmed; when longer than 8192 characters or 8192 UTF-8 bytes, cut to its most recent text within both bounds; not credential-scrubbed), Scope and preparation options; prepared context returns to Hermes | PowerContext Server | Active provider, nonempty query and resolved Scope; cached prefetch may be reused | Select a different memory provider to stop this provider's automatic recall; there is no separate recall switch here | PowerContext automatic recall stops; capture switches alone leave recall available |
| Completed turn | Bounded user/assistant text pair without secret redaction, plus session metadata; not the complete tool transcript | PowerContext Server, as a Source | `capture_turns=true`; automatic writes are suppressed outside the primary agent context | Set `POWERCONTEXT_HERMES_CAPTURE_TURNS=false` before entering sensitive text | Stops this Source capture; recall, pre-compression capture and explicit writes remain independent |
| Recall / prefetch | Query (trimmed; when longer than 8192 characters or 8192 UTF-8 bytes, cut to its most recent text within both bounds; recognized credentials replaced with `[REDACTED]`), Scope and preparation options; prepared context returns to Hermes | PowerContext Server | Active provider, nonempty query and resolved Scope; cached prefetch may be reused | Select a different memory provider to stop this provider's automatic recall; there is no separate recall switch here | PowerContext automatic recall stops; capture switches alone leave recall available |
| Completed turn | Bounded user/assistant text pair, plus session metadata; not the complete tool transcript. A turn whose user text contains a recognized credential is skipped as a whole; assistant text is not checked | PowerContext Server, as a Source | `capture_turns=true`; automatic writes are suppressed outside the primary agent context | Set `POWERCONTEXT_HERMES_CAPTURE_TURNS=false` before entering sensitive text | Stops this Source capture; recall, pre-compression capture and explicit writes remain independent |
| Session end | Flush request for already accepted inputs, not another upload of the session transcript | PowerContext Server | `flush_on_session_end=true`; waits for background writes and checks extraction capability | `POWERCONTEXT_HERMES_FLUSH_ON_SESSION_END=false` | Stops this flush trigger; accepted Sources remain and other processing triggers are unaffected |
| Before compression | New user/assistant evidence window, excluding system/tool messages and redacting detected secrets | PowerContext Server, as a Source | `capture_pre_compress=false`; opt in with `POWERCONTEXT_HERMES_CAPTURE_PRE_COMPRESS=true` | `POWERCONTEXT_HERMES_CAPTURE_PRE_COMPRESS=false` | Stops this capture and its subsequent extraction attempt; a required checkpoint fails rather than reporting success |
| Explicit remember / built-in memory mirror | Requested Memory content or change, with exact references for updates | PowerContext Server | Explicit operation, or primary-context `on_memory_write` for add/replace/remove | Do not invoke the write or mirror-producing built-in operation; no dedicated mirror switch | Turning off turn capture does not disable these writes |
| Evaluation trace | Prompt/query, recalled context and correlation metadata; detected secrets are redacted | Local JSONL files, by default under `$HERMES_HOME/powercontext/evaluation-trace/` | `evaluation_trace=false`; opt in with `POWERCONTEXT_HERMES_EVALUATION_TRACE=true` | `POWERCONTEXT_HERMES_EVALUATION_TRACE=false` | Stops new trace records without disabling recall or capture; existing files remain sensitive |

Recall requests and completed-turn Sources do not scrub credentials. Redaction of evaluation traces does not redact
the query already sent to the Server; pre-compression filtering applies only to that separate capture path.
Recall queries and completed-turn capture follow the [automatic prompt privacy](index.md#automatic-prompt-privacy)
policy: recognized credentials are replaced in the query, and a turn whose user text contains one is not captured.
Pre-compression capture redacts detected secrets with its own rules, which are separate from that policy and
recognize fewer credential formats. A turn that completed-turn capture skips can still reach the Server, redacted by
those rules, in a pre-compression window.

Pre-compression capture prefers the host-normalized `evidence_messages` when supplied, so earlier compression
summaries are not reintroduced as fresh evidence. The provider declares checkpoint API v2 and raises on an
Expand Down
16 changes: 16 additions & 0 deletions docs/en/docs/integrations/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,22 @@ when updating a plugin; this policy adds credential checks without changing capt
| ZCode | `UserPromptSubmit` text | `POWERCONTEXT_ZCODE_CAPTURE_PROMPTS=false` |
| Kimi Code (experimental) | Text parts of `UserPromptSubmit` | setup `--no-capture-prompts` |

The in-process Python adapters apply the same recognition and handling to their automatic paths without changing
their capture defaults:

| Adapter | Automatic input boundary | Checked automatic capture | Capture default |
| --- | --- | --- | --- |
| Hermes | `prefetch` and `queue_prefetch` query | Completed-turn Source | On; `POWERCONTEXT_HERMES_CAPTURE_TURNS=false` |
| LangChain | Latest human message | Completed-turn Source | Off; `PowerContextMiddleware(auto_capture=True)` |
| LangGraph | Latest human message | None; LangGraph captures only through explicit tools | Not applicable |
| Pydantic AI | Latest textual user prompt | `user_prompt` event | Off; `POWERCONTEXT_PYDANTIC_AI_CAPTURE_EVENTS=true` |

These adapters check the user text only. A recognized credential skips the whole completed turn (Hermes, LangChain)
or the `user_prompt` event (Pydantic AI); assistant text is not checked. Pydantic AI model-response and tool events keep
their key-based and known-credential redaction, and Hermes pre-compression capture keeps its own redaction. The
configured Server credential is the adapter's token, or Hermes's Authorization value. A skip is logged at debug level
with the reason `sensitive_content` and without the rejected text.

Before automatic capture, these adapters recognize conventional credential assignments (API/access keys
and tokens, client/private keys, secrets, passwords, passphrases, authorization and cookies), Bearer values
of at least eight token characters, common provider/GitHub/Slack token shapes, private-key blocks including
Expand Down
10 changes: 7 additions & 3 deletions docs/en/docs/integrations/langchain.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ instead of calling a synchronous method inside its event loop.
For every model step, the middleware:

1. reads the latest human message without changing state;
2. calls `/v1/context/prepare` with the resolved scope and configured byte limit. The query is the message, trimmed;
2. calls `/v1/context/prepare` with the resolved scope and configured byte limit. The query is the message, trimmed,
with recognized credentials replaced by `[REDACTED]` as described in
[automatic prompt privacy](index.md#automatic-prompt-privacy);
a message longer than 8,192 characters or 8,192 UTF-8 bytes recalls from its most recent text, cut to the last
8,192 characters and then to the last 8,192 bytes;
3. appends a separate text block to the current system message;
Expand All @@ -90,8 +92,10 @@ not store the recalled system block, tool outputs, or intermediate tool-calling

Capture creates Source evidence, not an inferred Memory entry. The configured scheduler or an explicit
`flush_memory` operation performs the normal Source-to-Memory extraction later. This keeps lineage intact and avoids
treating raw model output as an already reviewed durable fact. Captured content is bounded but is not guaranteed to be
free of secrets, so applications must apply their own input and output policy before opting in.
treating raw model output as an already reviewed durable fact. A turn whose user message contains a recognized
credential is skipped as a whole. Detection is best effort and the assistant response is not checked, so captured
content is not guaranteed to be free of secrets; applications must apply their own input and output policy before
opting in.

LangChain does not run `after_agent` when a model or tool aborts the run, so a failed run without a final response is
not captured.
Expand Down
5 changes: 3 additions & 2 deletions docs/en/docs/integrations/langgraph.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ from the Scope API rather than inventing it locally.

## Recall query

`PowerContextRecall` sends the latest human message, trimmed. A message longer than 8,192 characters or 8,192 UTF-8
bytes recalls from its most recent text, cut to the last 8,192 characters and then to the last 8,192 bytes.
`PowerContextRecall` sends the latest human message, trimmed, with recognized credentials replaced by `[REDACTED]` as
described in [automatic prompt privacy](index.md#automatic-prompt-privacy). A message longer than 8,192 characters or
8,192 UTF-8 bytes recalls from its most recent text, cut to the last 8,192 characters and then to the last 8,192 bytes.

## Treat recalled context as untrusted history

Expand Down
12 changes: 7 additions & 5 deletions docs/en/docs/integrations/pydantic-ai.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ agent = Agent(

The capability adds `powercontext_search`, `powercontext_remember`, and `powercontext_context`. It also requests
`prepare_context` from the latest textual user prompt and prepends at most one untrusted evidence block per run. A new
run prepares context again even when it starts from the previous run's message history. A prompt longer than 8,192
characters or 8,192 UTF-8 bytes recalls from its most recent text, cut to the last 8,192 characters and then to the
last 8,192 bytes.
run prepares context again even when it starts from the previous run's message history. The query is the prompt,
trimmed, with recognized credentials replaced by `[REDACTED]` as described in
[automatic prompt privacy](index.md#automatic-prompt-privacy). A prompt longer than 8,192 characters or 8,192 UTF-8
bytes recalls from its most recent text, cut to the last 8,192 characters and then to the last 8,192 bytes.

Use only the toolset when automatic preparation and capture are not wanted:

Expand Down Expand Up @@ -111,8 +112,9 @@ create Scope IDs.

Capture is off by default. Set `POWERCONTEXT_PYDANTIC_AI_CAPTURE_EVENTS=true` only when sending the initial user text,
visible model text and tool calls, and completed tool arguments and results to the configured scope is acceptable.
Thinking/reasoning content is excluded. Events are redacted for credential-like keys and known environment/Codex
credentials, rendered within the configured byte limit, and stored under
Thinking/reasoning content is excluded. A user prompt that contains a recognized credential is not captured; see
[automatic prompt privacy](index.md#automatic-prompt-privacy). Events are redacted for credential-like keys and known
environment/Codex credentials, rendered within the configured byte limit, and stored under
`powercontext.pydantic-ai-capture-event/v1`.

Every successful Capture advances the run-local Source position. A checkpoint Flush runs after the configured number
Expand Down
9 changes: 5 additions & 4 deletions docs/zh/docs/integrations/hermes.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,16 @@ Evaluation trace 包含 prompt 和召回上下文,应保留在本机并按敏

| 事件/入口 | 发送的数据 | 直接接收方 | 默认/触发条件 | 关闭方式 | 关闭后影响 |
| --- | --- | --- | --- | --- | --- |
| 召回 / prefetch | query(去掉首尾空白;超过 8192 个字符或 8192 个 UTF-8 字节时保留同时满足两项上限的最近文本;不做凭据脱敏)、Scope 和准备选项;Prepared Context 返回 Hermes | PowerContext Server | provider 已激活、query 非空且 Scope 已解析;可能复用预取缓存 | 切换 memory provider 可停止该 provider 的自动召回;此处没有独立召回开关 | PowerContext 自动召回停止;仅关闭捕获不影响召回 |
| 完成 turn | 有长度上限且不做 secret 脱敏的 user/assistant 文本对,以及 session 元数据;不是完整工具 transcript | PowerContext Server,保存为 Source | `capture_turns=true`;非主 Agent 上下文抑制自动写入 | 输入敏感文本前设置 `POWERCONTEXT_HERMES_CAPTURE_TURNS=false` | 停止该 Source 捕获;召回、压缩前捕获和显式写入仍独立工作 |
| 召回 / prefetch | query(去掉首尾空白;超过 8192 个字符或 8192 个 UTF-8 字节时保留同时满足两项上限的最近文本;识别到的凭据替换为 `[REDACTED]`)、Scope 和准备选项;Prepared Context 返回 Hermes | PowerContext Server | provider 已激活、query 非空且 Scope 已解析;可能复用预取缓存 | 切换 memory provider 可停止该 provider 的自动召回;此处没有独立召回开关 | PowerContext 自动召回停止;仅关闭捕获不影响召回 |
| 完成 turn | 有长度上限的 user/assistant 文本对,以及 session 元数据;不是完整工具 transcript。用户文本含可识别凭据的 turn 整条跳过;助手文本不做检查 | PowerContext Server,保存为 Source | `capture_turns=true`;非主 Agent 上下文抑制自动写入 | 输入敏感文本前设置 `POWERCONTEXT_HERMES_CAPTURE_TURNS=false` | 停止该 Source 捕获;召回、压缩前捕获和显式写入仍独立工作 |
| 会话结束 | 针对已接受输入的 flush 请求,不会重新上传会话 transcript | PowerContext Server | `flush_on_session_end=true`;等待后台写入并检查提取能力 | `POWERCONTEXT_HERMES_FLUSH_ON_SESSION_END=false` | 停止此 flush 触发;已接受的 Source 保留,其他处理触发不受影响 |
| 压缩前 | 新 user/assistant 证据窗口,排除 system/tool 消息并脱敏检测到的 secret | PowerContext Server,保存为 Source | `capture_pre_compress=false`;用 `POWERCONTEXT_HERMES_CAPTURE_PRE_COMPRESS=true` 显式开启 | `POWERCONTEXT_HERMES_CAPTURE_PRE_COMPRESS=false` | 停止此捕获及其后续提取尝试;必需 checkpoint 会失败而非报告成功 |
| 显式 remember / 内置 Memory mirror | 请求的 Memory 内容或变更,更新携带精确引用 | PowerContext Server | 显式操作,或主上下文中 add/replace/remove 的 `on_memory_write` | 不调用该写入或产生 mirror 的内置操作;没有专用 mirror 开关 | 关闭 turn 捕获不会禁用这些写入 |
| Evaluation trace | prompt/query、召回上下文及关联元数据;检测到的 secret 会脱敏 | 本地 JSONL 文件,默认位于 `$HERMES_HOME/powercontext/evaluation-trace/` | `evaluation_trace=false`;用 `POWERCONTEXT_HERMES_EVALUATION_TRACE=true` 显式开启 | `POWERCONTEXT_HERMES_EVALUATION_TRACE=false` | 停止新增 trace,不禁用召回或捕获;已有文件仍是敏感数据 |

召回请求与完成 turn 的 Source 不做凭据脱敏。Evaluation trace 的脱敏不会处理已经发送到 Server 的 query;
压缩前过滤只作用于那条独立的捕获路径。
召回 query 与完成 turn 捕获遵循[自动 prompt 隐私策略](index.md#自动-prompt-隐私策略):query 中识别到的凭据会被替换,
用户文本含凭据的 turn 不会被捕获。压缩前捕获使用自身规则脱敏检测到的 secret,与该策略相互独立,
能识别的凭据格式也更少。完成 turn 捕获跳过的 turn 仍可能出现在压缩前窗口中,按这些规则脱敏后发送到 Server。

压缩前捕获优先使用宿主提供的规范化 `evidence_messages`,避免把先前压缩摘要再次作为新证据。
provider 声明 checkpoint API v2,必需 checkpoint 未提交时会抛出异常。这描述的是 provider 契约:仓库的
Expand Down
14 changes: 14 additions & 0 deletions docs/zh/docs/integrations/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ powercontext setup
| ZCode | `UserPromptSubmit` 文本 | `POWERCONTEXT_ZCODE_CAPTURE_PROMPTS=false` |
| Kimi Code(实验性) | `UserPromptSubmit` 中的文本部分 | setup `--no-capture-prompts` |

进程内 Python 适配器在自动路径上使用同样的识别和处理方式,不改变各自的捕获默认值:

| 适配器 | 自动输入边界 | 受检查的自动捕获 | 捕获默认值 |
| --- | --- | --- | --- |
| Hermes | `prefetch` 和 `queue_prefetch` 的 query | 完成轮次的 Source | 开启;`POWERCONTEXT_HERMES_CAPTURE_TURNS=false` 关闭 |
| LangChain | 最新的人类消息 | 完成轮次的 Source | 关闭;`PowerContextMiddleware(auto_capture=True)` 开启 |
| LangGraph | 最新的人类消息 | 无;LangGraph 只通过显式工具写入 | 不适用 |
| Pydantic AI | 最新的文本 User Prompt | `user_prompt` 事件 | 关闭;`POWERCONTEXT_PYDANTIC_AI_CAPTURE_EVENTS=true` 开启 |

这些适配器只检查用户文本。识别到凭据时整轮跳过完成轮次捕获(Hermes、LangChain),或跳过 `user_prompt` 事件
(Pydantic AI);助手文本不做检查。Pydantic AI 的模型响应和工具事件继续按键名和已知凭据值脱敏,Hermes 的压缩前
捕获继续使用自身的脱敏规则。当前 Server 凭据指适配器配置的 token,或 Hermes 的 Authorization 值。跳过时在 debug
日志中记录原因 `sensitive_content`,不包含被拒绝的文本。

自动捕获前,适配器识别常见凭据赋值(API/access key 和 token、client/private key、secret、password、
passphrase、authorization、cookie)、至少八个 token 字符的 Bearer 值、常见服务商/GitHub/Slack token
形状、包含未闭合情况的私钥块,以及当前 Server 凭据在输入中的精确出现。这是尽力识别:未知格式、混淆或
Expand Down
10 changes: 6 additions & 4 deletions docs/zh/docs/integrations/langchain.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ middleware 本身支持同步 `invoke` 和 `stream`;异步应用应直接使
每个模型步骤中,middleware 都会:

1. 读取最新的人类消息,不修改 state;
2. 使用解析后的 scope 和字节上限调用 `/v1/context/prepare`。query 是去掉首尾空白的该消息;超过 8192 个字符或
8192 个 UTF-8 字节的消息改用最近的文本召回,先取末尾 8192 个字符,再截到末尾 8192 字节;
2. 使用解析后的 scope 和字节上限调用 `/v1/context/prepare`。query 是去掉首尾空白的该消息,识别到的凭据按
[自动 prompt 隐私策略](index.md#自动-prompt-隐私策略)替换为 `[REDACTED]`;超过 8192 个字符或 8192 个 UTF-8
字节的消息改用最近的文本召回,先取末尾 8192 个字符,再截到末尾 8192 字节;
3. 向当前 system message 追加一个独立文本块;
4. 文本块以 `PowerContext host-supplied context` 开头,后接 Server 准备的内容;
内容顶部的信任策略把其后的全部内容标为不可信的历史数据。
Expand All @@ -85,8 +86,9 @@ middleware = PowerContextMiddleware(auto_capture=True)
LangChain 的 `structured_response` 序列化。采集不包含召回 system block、工具输出或中间的 tool-calling 模型消息。

采集结果是 Source 证据,不是推断完成的 Memory entry。配置的 scheduler 或显式 `flush_memory` 操作随后执行标准的
Source-to-Memory 抽取。这样既保留 lineage,也不会把未经处理的模型输出直接当成已经审核的持久事实。采集内容有长度
上限,但不保证一定不含 secret;应用必须先执行自己的输入和输出策略,再选择开启。
Source-to-Memory 抽取。这样既保留 lineage,也不会把未经处理的模型输出直接当成已经审核的持久事实。用户消息含可识别
凭据的轮次整轮跳过。识别是尽力而为,且不检查回答,因此采集内容不保证一定不含 secret;应用必须先执行自己的输入和
输出策略,再选择开启。

模型或工具中止运行时,LangChain 不会执行 `after_agent`;因此,没有最终回答的失败运行不会被采集。

Expand Down
Loading
Loading