@miller-tech/uap 1.77.0 → 1.79.0
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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/cli/deliver.d.ts +11 -0
- package/dist/cli/deliver.d.ts.map +1 -1
- package/dist/cli/deliver.js +25 -1
- package/dist/cli/deliver.js.map +1 -1
- package/dist/coordination/reactor.d.ts.map +1 -1
- package/dist/coordination/reactor.js +8 -1
- package/dist/coordination/reactor.js.map +1 -1
- package/package.json +1 -1
- package/src/policies/enforcers/__pycache__/_common.cpython-312.pyc +0 -0
- package/src/policies/enforcers/delivery_enforcement.py +10 -1
- package/src/policies/enforcers/enforcement_self_protect.py +119 -0
- package/src/policies/schemas/policies/enforcement-self-protect.md +24 -0
- package/tools/agents/scripts/__pycache__/toolcall_path_normalizer.cpython-312.pyc +0 -0
- package/tools/agents/scripts/anthropic_proxy.py +16 -0
- package/tools/agents/tests/test_enforcement_self_protect.py +71 -0
- package/tools/agents/tests/test_stream_required_tool.py +60 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"""Tests for A2: env-gated stream-passthrough on required-tool turns.
|
|
2
|
+
|
|
3
|
+
Default (off): a streaming required-tool turn is buffered via the guarded
|
|
4
|
+
non-stream path (so the tool call can be validated/repaired). When
|
|
5
|
+
PROXY_STREAM_REQUIRED_TOOL is on, it streams through instead. force-non-stream
|
|
6
|
+
and malformed-strict still buffer regardless.
|
|
7
|
+
"""
|
|
8
|
+
import importlib.util
|
|
9
|
+
import unittest
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
proxy_path = Path(__file__).resolve().parents[1] / "scripts" / "anthropic_proxy.py"
|
|
13
|
+
spec = importlib.util.spec_from_file_location("anthropic_proxy", proxy_path)
|
|
14
|
+
ap = importlib.util.module_from_spec(spec)
|
|
15
|
+
spec.loader.exec_module(ap)
|
|
16
|
+
|
|
17
|
+
TOOLS_BODY = {"tools": [{"name": "x"}], "messages": []}
|
|
18
|
+
REQUIRED = {"tool_choice": "required"}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class StreamRequiredToolTest(unittest.TestCase):
|
|
22
|
+
def setUp(self):
|
|
23
|
+
self._saved = ap.PROXY_STREAM_REQUIRED_TOOL
|
|
24
|
+
|
|
25
|
+
def tearDown(self):
|
|
26
|
+
ap.PROXY_STREAM_REQUIRED_TOOL = self._saved
|
|
27
|
+
|
|
28
|
+
def test_default_off_buffers_required_tool_stream(self):
|
|
29
|
+
ap.PROXY_STREAM_REQUIRED_TOOL = False
|
|
30
|
+
self.assertTrue(
|
|
31
|
+
ap._should_use_guarded_non_stream(True, TOOLS_BODY, REQUIRED),
|
|
32
|
+
"default must buffer required-tool streaming turns",
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
def test_on_streams_required_tool_through(self):
|
|
36
|
+
ap.PROXY_STREAM_REQUIRED_TOOL = True
|
|
37
|
+
self.assertFalse(
|
|
38
|
+
ap._should_use_guarded_non_stream(True, TOOLS_BODY, REQUIRED),
|
|
39
|
+
"passthrough must NOT buffer required-tool turns when enabled",
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
def test_force_non_stream_still_buffers_even_when_passthrough_on(self):
|
|
43
|
+
ap.PROXY_STREAM_REQUIRED_TOOL = True
|
|
44
|
+
saved = ap.PROXY_FORCE_NON_STREAM
|
|
45
|
+
try:
|
|
46
|
+
ap.PROXY_FORCE_NON_STREAM = True
|
|
47
|
+
self.assertTrue(
|
|
48
|
+
ap._should_use_guarded_non_stream(True, TOOLS_BODY, REQUIRED),
|
|
49
|
+
"force-non-stream overrides passthrough",
|
|
50
|
+
)
|
|
51
|
+
finally:
|
|
52
|
+
ap.PROXY_FORCE_NON_STREAM = saved
|
|
53
|
+
|
|
54
|
+
def test_non_stream_request_never_guarded(self):
|
|
55
|
+
ap.PROXY_STREAM_REQUIRED_TOOL = False
|
|
56
|
+
self.assertFalse(ap._should_use_guarded_non_stream(False, TOOLS_BODY, REQUIRED))
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
if __name__ == "__main__":
|
|
60
|
+
unittest.main()
|