Skip to main content

agent-protocol-core

识别「模型协议残片漏进了正文」。纯标准库,零依赖。

模型的原始输出里带着协议层的东西 —— 通道标记、工具路由、思考标签、 被截断的 JSON 尾巴。这些不该出现在给人看的文本里:用户会在聊天窗口 或记忆卡里看到一串乱码,而系统那边一切正常,没有任何报错。

这个包只做识别,不做处置 —— 怎么处置(打回重问、就地清洗、直接丢弃) 是调用方的决定,不同场景代价不同。

from agent_protocol_core import protocol_leak, self_thinking

protocol_leak.is_orphan_json_tail(text)   # 闭括号比开括号多,且带 JSON 记号
self_thinking.strip_thinking(text)        # 思考标记

为什么单独一个包

聊天和记忆两条路都要这个判断。放在任何一边,另一边就得跨模块引用; 各写一份则会漂 —— 改了一边忘了另一边,同一段脏文本在两条路上待遇不同。

memgarden 同仓库、锁步发版。

Apache-2.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agent_protocol_core-0.12.4.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agent_protocol_core-0.12.4-py3-none-any.whl (24.3 kB view details)

Uploaded Python 3

File details

Details for the file agent_protocol_core-0.12.4.tar.gz.

File metadata

  • Download URL: agent_protocol_core-0.12.4.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for agent_protocol_core-0.12.4.tar.gz
Algorithm Hash digest
SHA256 d2f770d7b7c7a6f9590d85817a6b211ce61f095c0f7ed3e299afe916c16b4a29
MD5 e3636cab616b76e32da2d4c6ae3f0304
BLAKE2b-256 2b6b3f3b28b506c79ea3bff97538d9d0d80588a7047b2106b6d985c7f0f0a225

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_protocol_core-0.12.4.tar.gz:

Publisher: release.yml on teleport-computer/memgarden

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file agent_protocol_core-0.12.4-py3-none-any.whl.

File metadata

File hashes

Hashes for agent_protocol_core-0.12.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0dde56e91408ed5a2dcc4b9e994cb489e7e07c2a85f27d7a00a0b97b0c57ab84
MD5 9964d7d35724ed9f3cb5fbb18afe411b
BLAKE2b-256 c4926ffabb1d03ab6b29acf53315b91e8aeb2ff9bb871e6d177dee9e5007be63

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_protocol_core-0.12.4-py3-none-any.whl:

Publisher: release.yml on teleport-computer/memgarden

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.12.10

2 files

0.12.9

2 files

0.12.8

2 files

0.12.7

2 files

0.12.6

2 files

0.12.5

2 files

This release

0.12.4 This release

2 files

0.12.3

2 files

0.12.2

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page