rpcs1 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.
- rpcs1-0.1.0/.gitignore +16 -0
- rpcs1-0.1.0/PKG-INFO +134 -0
- rpcs1-0.1.0/README.md +102 -0
- rpcs1-0.1.0/examples/anthropic_integration.py +44 -0
- rpcs1-0.1.0/examples/basic_usage.py +63 -0
- rpcs1-0.1.0/examples/trading_ea_bridge.py +36 -0
- rpcs1-0.1.0/pyproject.toml +56 -0
- rpcs1-0.1.0/src/rpcs1/__init__.py +42 -0
- rpcs1-0.1.0/src/rpcs1/adapters.py +38 -0
- rpcs1-0.1.0/src/rpcs1/analysis.py +147 -0
- rpcs1-0.1.0/src/rpcs1/config/matching.json +26 -0
- rpcs1-0.1.0/src/rpcs1/config/neurotypes.json +37 -0
- rpcs1-0.1.0/src/rpcs1/config/platforms.json +66 -0
- rpcs1-0.1.0/src/rpcs1/integrations/__init__.py +1 -0
- rpcs1-0.1.0/src/rpcs1/integrations/anthropic.py +61 -0
- rpcs1-0.1.0/src/rpcs1/integrations/openai.py +63 -0
- rpcs1-0.1.0/src/rpcs1/matching.py +51 -0
- rpcs1-0.1.0/src/rpcs1/platforms.py +138 -0
- rpcs1-0.1.0/src/rpcs1/primitives.py +109 -0
- rpcs1-0.1.0/src/rpcs1/recommend.py +126 -0
- rpcs1-0.1.0/src/rpcs1/types.py +106 -0
- rpcs1-0.1.0/tests/conftest.py +11 -0
- rpcs1-0.1.0/tests/test_adapters.py +25 -0
- rpcs1-0.1.0/tests/test_parity.py +147 -0
- rpcs1-0.1.0/tests/test_primitives.py +113 -0
- rpcs1-0.1.0/tests/test_recommend.py +189 -0
rpcs1-0.1.0/.gitignore
ADDED
rpcs1-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rpcs1
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: RPCS-1 Agent Tuner — configuration framework for AI agents grounded in receiver dynamics
|
|
5
|
+
Project-URL: Homepage, https://rpcs1.dev
|
|
6
|
+
Project-URL: Documentation, https://rpcs1.dev/docs
|
|
7
|
+
Project-URL: Repository, https://github.com/travisbergen2/rpcs1-sdk
|
|
8
|
+
Project-URL: Issues, https://github.com/travisbergen2/rpcs1-sdk/issues
|
|
9
|
+
Author-email: Travis Bergen <travisbergen2@gmail.com>
|
|
10
|
+
License: MIT
|
|
11
|
+
Keywords: agents,ai,configuration,llm,rpcs1,tuning
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Requires-Dist: pydantic>=2.0
|
|
21
|
+
Provides-Extra: anthropic
|
|
22
|
+
Requires-Dist: anthropic>=0.25; extra == 'anthropic'
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
25
|
+
Requires-Dist: pydantic>=2.0; extra == 'dev'
|
|
26
|
+
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
28
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
29
|
+
Provides-Extra: openai
|
|
30
|
+
Requires-Dist: openai>=1.0; extra == 'openai'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# rpcs1 — AI Agent Parameter Tuner
|
|
34
|
+
|
|
35
|
+
**Configure AI agents that don't oscillate, overload, or freeze.**
|
|
36
|
+
|
|
37
|
+
Stop debugging agent failures case-by-case. The RPCS-1 SDK translates your agent's task and environment into specific platform parameters — grounded in receiver dynamics from cognitive systems research.
|
|
38
|
+
|
|
39
|
+
Built on the matching principle: agents in fast-changing environments need short attention windows; agents in stable environments benefit from longer integration.
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pip install rpcs1
|
|
45
|
+
# With Anthropic integration:
|
|
46
|
+
pip install rpcs1[anthropic]
|
|
47
|
+
# With OpenAI integration:
|
|
48
|
+
pip install rpcs1[openai]
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Quick Start
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from rpcs1 import recommend_params
|
|
55
|
+
|
|
56
|
+
config = recommend_params(
|
|
57
|
+
task_description="Customer support agent handling refund requests",
|
|
58
|
+
environment_entropy="dynamic", # stable | moderate | dynamic | chaotic
|
|
59
|
+
environment_predictability="somewhat_predictable",
|
|
60
|
+
stakes="high", # low | medium | high | catastrophic
|
|
61
|
+
context_relevance="medium", # short | medium | long
|
|
62
|
+
commitment_style="cautious", # decisive | balanced | cautious
|
|
63
|
+
target_platform="anthropic", # anthropic | openai | open_source | generic
|
|
64
|
+
domain="customer_support", # optional
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
print(config.platform_parameters.temperature) # e.g. 0.52
|
|
68
|
+
print(config.platform_parameters.model_recommendation) # e.g. 'claude-sonnet-4-6'
|
|
69
|
+
print(config.predicted_regime) # 'stable'
|
|
70
|
+
print(config.reasoning) # cites Matching Principle (Pred-09-5)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## The Five Receiver Primitives
|
|
74
|
+
|
|
75
|
+
Every recommendation is driven by five receiver primitives from RPCS-1:
|
|
76
|
+
|
|
77
|
+
| Primitive | Name | What it controls |
|
|
78
|
+
|---|---|---|
|
|
79
|
+
| **TI** | Temporal Integration | How much history to integrate (context window strategy) |
|
|
80
|
+
| **SG** | Signal Gain | How strongly to amplify signals (temperature) |
|
|
81
|
+
| **FT** | Filtering Threshold | How conservatively to gate action (tool use strategy) |
|
|
82
|
+
| **UE** | Update Elasticity | How readily to revise the model (retry strategy) |
|
|
83
|
+
| **AR** | Ambiguity Resolution | How aggressively to resolve uncertainty |
|
|
84
|
+
|
|
85
|
+
## Stability Regimes
|
|
86
|
+
|
|
87
|
+
The SDK predicts and warns about four stability regimes:
|
|
88
|
+
|
|
89
|
+
- **stable** — balanced operation, well-matched to environment
|
|
90
|
+
- **near_oscillation** — high TI + high SG → agent revisits decisions, won't commit
|
|
91
|
+
- **near_overload** — low TI + high SG → agent acts on insufficient information
|
|
92
|
+
- **near_freeze** — low UE + high FT → agent hedges endlessly, won't act
|
|
93
|
+
|
|
94
|
+
## Anthropic Integration
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from rpcs1 import recommend_params
|
|
98
|
+
from rpcs1.integrations.anthropic import to_anthropic_params
|
|
99
|
+
import anthropic
|
|
100
|
+
|
|
101
|
+
rec = recommend_params(
|
|
102
|
+
task_description="Medical triage assistant",
|
|
103
|
+
environment_entropy="moderate",
|
|
104
|
+
environment_predictability="somewhat_predictable",
|
|
105
|
+
stakes="catastrophic",
|
|
106
|
+
commitment_style="cautious",
|
|
107
|
+
target_platform="anthropic",
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
params = to_anthropic_params(
|
|
111
|
+
rec,
|
|
112
|
+
system_prompt="You are a medical intake assistant.",
|
|
113
|
+
user_message="I've had chest pain for an hour.",
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
client = anthropic.Anthropic()
|
|
117
|
+
message = client.messages.create(**params)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Theoretical Foundation
|
|
121
|
+
|
|
122
|
+
The RPCS-1 SDK implements the matching principle (Pred-09-5) from IMM Paper 9:
|
|
123
|
+
|
|
124
|
+
> Stable receivers in an environment with entropy H satisfy TI ~ 1/H.
|
|
125
|
+
|
|
126
|
+
This translates directly: agents in chaotic environments need short attention windows (low TI, frequent grounding); agents in stable environments benefit from long integration (high TI, large context windows).
|
|
127
|
+
|
|
128
|
+
All parameter recommendations are deterministic, explainable, and traceable to specific IMM principles. No ML models, no black-box recommendations.
|
|
129
|
+
|
|
130
|
+
## License
|
|
131
|
+
|
|
132
|
+
MIT — see LICENSE file.
|
|
133
|
+
|
|
134
|
+
Web app and full documentation: [https://rpcs1.dev](https://rpcs1.dev)
|
rpcs1-0.1.0/README.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# rpcs1 — AI Agent Parameter Tuner
|
|
2
|
+
|
|
3
|
+
**Configure AI agents that don't oscillate, overload, or freeze.**
|
|
4
|
+
|
|
5
|
+
Stop debugging agent failures case-by-case. The RPCS-1 SDK translates your agent's task and environment into specific platform parameters — grounded in receiver dynamics from cognitive systems research.
|
|
6
|
+
|
|
7
|
+
Built on the matching principle: agents in fast-changing environments need short attention windows; agents in stable environments benefit from longer integration.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install rpcs1
|
|
13
|
+
# With Anthropic integration:
|
|
14
|
+
pip install rpcs1[anthropic]
|
|
15
|
+
# With OpenAI integration:
|
|
16
|
+
pip install rpcs1[openai]
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
from rpcs1 import recommend_params
|
|
23
|
+
|
|
24
|
+
config = recommend_params(
|
|
25
|
+
task_description="Customer support agent handling refund requests",
|
|
26
|
+
environment_entropy="dynamic", # stable | moderate | dynamic | chaotic
|
|
27
|
+
environment_predictability="somewhat_predictable",
|
|
28
|
+
stakes="high", # low | medium | high | catastrophic
|
|
29
|
+
context_relevance="medium", # short | medium | long
|
|
30
|
+
commitment_style="cautious", # decisive | balanced | cautious
|
|
31
|
+
target_platform="anthropic", # anthropic | openai | open_source | generic
|
|
32
|
+
domain="customer_support", # optional
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
print(config.platform_parameters.temperature) # e.g. 0.52
|
|
36
|
+
print(config.platform_parameters.model_recommendation) # e.g. 'claude-sonnet-4-6'
|
|
37
|
+
print(config.predicted_regime) # 'stable'
|
|
38
|
+
print(config.reasoning) # cites Matching Principle (Pred-09-5)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## The Five Receiver Primitives
|
|
42
|
+
|
|
43
|
+
Every recommendation is driven by five receiver primitives from RPCS-1:
|
|
44
|
+
|
|
45
|
+
| Primitive | Name | What it controls |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| **TI** | Temporal Integration | How much history to integrate (context window strategy) |
|
|
48
|
+
| **SG** | Signal Gain | How strongly to amplify signals (temperature) |
|
|
49
|
+
| **FT** | Filtering Threshold | How conservatively to gate action (tool use strategy) |
|
|
50
|
+
| **UE** | Update Elasticity | How readily to revise the model (retry strategy) |
|
|
51
|
+
| **AR** | Ambiguity Resolution | How aggressively to resolve uncertainty |
|
|
52
|
+
|
|
53
|
+
## Stability Regimes
|
|
54
|
+
|
|
55
|
+
The SDK predicts and warns about four stability regimes:
|
|
56
|
+
|
|
57
|
+
- **stable** — balanced operation, well-matched to environment
|
|
58
|
+
- **near_oscillation** — high TI + high SG → agent revisits decisions, won't commit
|
|
59
|
+
- **near_overload** — low TI + high SG → agent acts on insufficient information
|
|
60
|
+
- **near_freeze** — low UE + high FT → agent hedges endlessly, won't act
|
|
61
|
+
|
|
62
|
+
## Anthropic Integration
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from rpcs1 import recommend_params
|
|
66
|
+
from rpcs1.integrations.anthropic import to_anthropic_params
|
|
67
|
+
import anthropic
|
|
68
|
+
|
|
69
|
+
rec = recommend_params(
|
|
70
|
+
task_description="Medical triage assistant",
|
|
71
|
+
environment_entropy="moderate",
|
|
72
|
+
environment_predictability="somewhat_predictable",
|
|
73
|
+
stakes="catastrophic",
|
|
74
|
+
commitment_style="cautious",
|
|
75
|
+
target_platform="anthropic",
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
params = to_anthropic_params(
|
|
79
|
+
rec,
|
|
80
|
+
system_prompt="You are a medical intake assistant.",
|
|
81
|
+
user_message="I've had chest pain for an hour.",
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
client = anthropic.Anthropic()
|
|
85
|
+
message = client.messages.create(**params)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Theoretical Foundation
|
|
89
|
+
|
|
90
|
+
The RPCS-1 SDK implements the matching principle (Pred-09-5) from IMM Paper 9:
|
|
91
|
+
|
|
92
|
+
> Stable receivers in an environment with entropy H satisfy TI ~ 1/H.
|
|
93
|
+
|
|
94
|
+
This translates directly: agents in chaotic environments need short attention windows (low TI, frequent grounding); agents in stable environments benefit from long integration (high TI, large context windows).
|
|
95
|
+
|
|
96
|
+
All parameter recommendations are deterministic, explainable, and traceable to specific IMM principles. No ML models, no black-box recommendations.
|
|
97
|
+
|
|
98
|
+
## License
|
|
99
|
+
|
|
100
|
+
MIT — see LICENSE file.
|
|
101
|
+
|
|
102
|
+
Web app and full documentation: [https://rpcs1.dev](https://rpcs1.dev)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""
|
|
2
|
+
RPCS-1 + Anthropic integration example.
|
|
3
|
+
|
|
4
|
+
Install: pip install rpcs1[anthropic]
|
|
5
|
+
"""
|
|
6
|
+
from rpcs1 import recommend_params
|
|
7
|
+
from rpcs1.integrations.anthropic import to_anthropic_params
|
|
8
|
+
|
|
9
|
+
# Get RPCS-1 recommendations for a medical triage agent
|
|
10
|
+
rec = recommend_params(
|
|
11
|
+
task_description="Medical intake assistant that triages patient symptoms and recommends urgency level",
|
|
12
|
+
environment_entropy="moderate",
|
|
13
|
+
environment_predictability="somewhat_predictable",
|
|
14
|
+
stakes="catastrophic",
|
|
15
|
+
context_relevance="medium",
|
|
16
|
+
commitment_style="cautious",
|
|
17
|
+
target_platform="anthropic",
|
|
18
|
+
domain="healthcare",
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
# Convert to Anthropic API parameters
|
|
22
|
+
system_prompt = "You are a medical intake assistant. You help patients describe their symptoms."
|
|
23
|
+
user_message = "I've had a headache and fever for two days."
|
|
24
|
+
|
|
25
|
+
params = to_anthropic_params(
|
|
26
|
+
rec,
|
|
27
|
+
system_prompt=system_prompt,
|
|
28
|
+
user_message=user_message,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
print("=== Anthropic API Parameters from RPCS-1 ===")
|
|
32
|
+
print(f"Model: {params['model']}")
|
|
33
|
+
print(f"Temperature: {params['temperature']}")
|
|
34
|
+
print(f"Max tokens: {params['max_tokens']}")
|
|
35
|
+
print(f"\nSystem prompt (first 100 chars):")
|
|
36
|
+
print(f" {params['system'][:100]}...")
|
|
37
|
+
print(f"\nRegime: {rec.predicted_regime}")
|
|
38
|
+
print(f"Confidence: {rec.confidence}")
|
|
39
|
+
|
|
40
|
+
# To actually call the API:
|
|
41
|
+
# import anthropic
|
|
42
|
+
# client = anthropic.Anthropic()
|
|
43
|
+
# message = client.messages.create(**params)
|
|
44
|
+
# print(message.content[0].text)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"""
|
|
2
|
+
RPCS-1 Python SDK — basic usage example.
|
|
3
|
+
|
|
4
|
+
Install: pip install rpcs1
|
|
5
|
+
"""
|
|
6
|
+
from rpcs1 import recommend_params
|
|
7
|
+
|
|
8
|
+
# -------------------------------------------------------------------
|
|
9
|
+
# Example 1: Customer support agent (high entropy, high stakes)
|
|
10
|
+
# -------------------------------------------------------------------
|
|
11
|
+
rec = recommend_params(
|
|
12
|
+
task_description="Customer support agent handling refund requests and billing disputes",
|
|
13
|
+
environment_entropy="dynamic",
|
|
14
|
+
environment_predictability="somewhat_predictable",
|
|
15
|
+
stakes="high",
|
|
16
|
+
context_relevance="medium",
|
|
17
|
+
commitment_style="cautious",
|
|
18
|
+
target_platform="anthropic",
|
|
19
|
+
domain="customer_support",
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
print("=== Example 1: Customer Support Agent ===")
|
|
23
|
+
print(f"Predicted regime: {rec.predicted_regime}")
|
|
24
|
+
print(f"\nReceiver profile:")
|
|
25
|
+
print(f" TI (Temporal Integration): {rec.receiver_profile.TI}")
|
|
26
|
+
print(f" SG (Signal Gain): {rec.receiver_profile.SG}")
|
|
27
|
+
print(f" FT (Filtering Threshold): {rec.receiver_profile.FT}")
|
|
28
|
+
print(f" UE (Update Elasticity): {rec.receiver_profile.UE}")
|
|
29
|
+
print(f" AR (Ambiguity Resolution): {rec.receiver_profile.AR}")
|
|
30
|
+
print(f"\nPlatform parameters:")
|
|
31
|
+
print(f" temperature: {rec.platform_parameters.temperature}")
|
|
32
|
+
print(f" max_tokens: {rec.platform_parameters.max_tokens}")
|
|
33
|
+
print(f" model: {rec.platform_parameters.model_recommendation}")
|
|
34
|
+
print(f" tool_use_strategy: {rec.platform_parameters.tool_use_strategy}")
|
|
35
|
+
print(f" context_strategy: {rec.platform_parameters.context_strategy}")
|
|
36
|
+
print(f"\nReasoning:\n {rec.reasoning}")
|
|
37
|
+
if rec.warnings:
|
|
38
|
+
print(f"\nWarnings:")
|
|
39
|
+
for w in rec.warnings:
|
|
40
|
+
print(f" ⚠ {w}")
|
|
41
|
+
print(f"\nIMM principles applied:")
|
|
42
|
+
for p in rec.imm_principles_applied:
|
|
43
|
+
print(f" • {p}")
|
|
44
|
+
|
|
45
|
+
# -------------------------------------------------------------------
|
|
46
|
+
# Example 2: CI/CD automation agent (low entropy, low stakes)
|
|
47
|
+
# -------------------------------------------------------------------
|
|
48
|
+
print("\n\n=== Example 2: CI/CD Automation Agent ===")
|
|
49
|
+
rec2 = recommend_params(
|
|
50
|
+
task_description="Automated CI pipeline agent that runs tests and deploys on green",
|
|
51
|
+
environment_entropy="stable",
|
|
52
|
+
environment_predictability="highly_predictable",
|
|
53
|
+
stakes="low",
|
|
54
|
+
context_relevance="short",
|
|
55
|
+
commitment_style="decisive",
|
|
56
|
+
target_platform="openai",
|
|
57
|
+
domain="devops",
|
|
58
|
+
)
|
|
59
|
+
print(f"Predicted regime: {rec2.predicted_regime}")
|
|
60
|
+
print(f"temperature: {rec2.platform_parameters.temperature}")
|
|
61
|
+
print(f"tool strategy: {rec2.platform_parameters.tool_use_strategy}")
|
|
62
|
+
print(f"TI: {rec2.receiver_profile.TI}")
|
|
63
|
+
print(f"AR: {rec2.receiver_profile.AR}")
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from rpcs1 import recommend_params, to_runtime_config
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def recommend_for_market(coherence: float, momentum: float) -> dict:
|
|
5
|
+
entropy = "dynamic"
|
|
6
|
+
commitment = "cautious"
|
|
7
|
+
|
|
8
|
+
if coherence < 0.50:
|
|
9
|
+
entropy = "chaotic"
|
|
10
|
+
commitment = "cautious"
|
|
11
|
+
elif abs(momentum) > 0.01:
|
|
12
|
+
entropy = "moderate"
|
|
13
|
+
commitment = "balanced"
|
|
14
|
+
|
|
15
|
+
rec = recommend_params(
|
|
16
|
+
task_description="Adaptive trading expert advisor",
|
|
17
|
+
environment_entropy=entropy,
|
|
18
|
+
environment_predictability="somewhat_predictable",
|
|
19
|
+
stakes="high",
|
|
20
|
+
context_relevance="short",
|
|
21
|
+
commitment_style=commitment,
|
|
22
|
+
target_platform="generic",
|
|
23
|
+
domain="trading",
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
return to_runtime_config(rec)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
if __name__ == "__main__":
|
|
30
|
+
config = recommend_for_market(coherence=0.471, momentum=0.00283)
|
|
31
|
+
print(
|
|
32
|
+
"[RPCS-1 SDK] Regime: {regime} | Temp: {temperature:.2f} | "
|
|
33
|
+
"TI: {TI:.0f} | SG: {SG:.0f} | FT: {FT:.0f} | Confidence: {confidence}".format(
|
|
34
|
+
**config
|
|
35
|
+
)
|
|
36
|
+
)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "rpcs1"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "RPCS-1 Agent Tuner — configuration framework for AI agents grounded in receiver dynamics"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
authors = [{ name = "Travis Bergen", email = "travisbergen2@gmail.com" }]
|
|
12
|
+
requires-python = ">=3.10"
|
|
13
|
+
dependencies = [
|
|
14
|
+
"pydantic>=2.0",
|
|
15
|
+
]
|
|
16
|
+
keywords = ["ai", "agents", "llm", "configuration", "tuning", "rpcs1"]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Development Status :: 3 - Alpha",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[project.urls]
|
|
28
|
+
Homepage = "https://rpcs1.dev"
|
|
29
|
+
Documentation = "https://rpcs1.dev/docs"
|
|
30
|
+
Repository = "https://github.com/travisbergen2/rpcs1-sdk"
|
|
31
|
+
Issues = "https://github.com/travisbergen2/rpcs1-sdk/issues"
|
|
32
|
+
|
|
33
|
+
[project.optional-dependencies]
|
|
34
|
+
anthropic = ["anthropic>=0.25"]
|
|
35
|
+
openai = ["openai>=1.0"]
|
|
36
|
+
dev = [
|
|
37
|
+
"pytest>=8.0",
|
|
38
|
+
"pytest-cov>=5.0",
|
|
39
|
+
"ruff>=0.4",
|
|
40
|
+
"mypy>=1.10",
|
|
41
|
+
"pydantic>=2.0",
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
[tool.hatch.build.targets.wheel]
|
|
45
|
+
packages = ["src/rpcs1"]
|
|
46
|
+
|
|
47
|
+
[tool.pytest.ini_options]
|
|
48
|
+
testpaths = ["tests"]
|
|
49
|
+
|
|
50
|
+
[tool.ruff]
|
|
51
|
+
line-length = 100
|
|
52
|
+
target-version = "py310"
|
|
53
|
+
|
|
54
|
+
[tool.mypy]
|
|
55
|
+
python_version = "3.10"
|
|
56
|
+
strict = true
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""
|
|
2
|
+
RPCS-1 Agent Tuner — Python SDK.
|
|
3
|
+
|
|
4
|
+
Quick start:
|
|
5
|
+
from rpcs1 import recommend_params
|
|
6
|
+
|
|
7
|
+
config = recommend_params(
|
|
8
|
+
task_description="Customer support agent",
|
|
9
|
+
environment_entropy="dynamic",
|
|
10
|
+
environment_predictability="somewhat_predictable",
|
|
11
|
+
stakes="high",
|
|
12
|
+
target_platform="anthropic",
|
|
13
|
+
)
|
|
14
|
+
print(config.platform_parameters.temperature)
|
|
15
|
+
print(config.predicted_regime)
|
|
16
|
+
print(config.reasoning)
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from .recommend import recommend_params, recommend_from_input
|
|
20
|
+
from .adapters import to_runtime_config
|
|
21
|
+
from .types import (
|
|
22
|
+
AgentEnvironment,
|
|
23
|
+
TaskDescriptor,
|
|
24
|
+
RecommendInput,
|
|
25
|
+
ReceiverProfile,
|
|
26
|
+
PlatformParameters,
|
|
27
|
+
Recommendation,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
__all__ = [
|
|
31
|
+
"recommend_params",
|
|
32
|
+
"recommend_from_input",
|
|
33
|
+
"to_runtime_config",
|
|
34
|
+
"AgentEnvironment",
|
|
35
|
+
"TaskDescriptor",
|
|
36
|
+
"RecommendInput",
|
|
37
|
+
"ReceiverProfile",
|
|
38
|
+
"PlatformParameters",
|
|
39
|
+
"Recommendation",
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Adapters for turning RPCS-1 recommendations into integration-friendly payloads.
|
|
3
|
+
"""
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from .types import Recommendation
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def to_runtime_config(recommendation: Recommendation) -> dict[str, Any]:
|
|
12
|
+
"""
|
|
13
|
+
Flatten a Recommendation into a simple runtime payload.
|
|
14
|
+
|
|
15
|
+
This is useful for EA bridges, dashboards, web APIs, and logging code that
|
|
16
|
+
should not need to know the nested Pydantic model structure.
|
|
17
|
+
"""
|
|
18
|
+
profile = recommendation.receiver_profile
|
|
19
|
+
params = recommendation.platform_parameters
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
"regime": recommendation.predicted_regime,
|
|
23
|
+
"confidence": recommendation.confidence,
|
|
24
|
+
"reasoning": recommendation.reasoning,
|
|
25
|
+
"warnings": recommendation.warnings,
|
|
26
|
+
"TI": profile.TI,
|
|
27
|
+
"SG": profile.SG,
|
|
28
|
+
"FT": profile.FT,
|
|
29
|
+
"UE": profile.UE,
|
|
30
|
+
"AR": profile.AR,
|
|
31
|
+
"temperature": params.temperature,
|
|
32
|
+
"top_p": params.top_p,
|
|
33
|
+
"max_tokens": params.max_tokens,
|
|
34
|
+
"model_recommendation": params.model_recommendation,
|
|
35
|
+
"tool_use_strategy": params.tool_use_strategy,
|
|
36
|
+
"retry_strategy": params.retry_strategy,
|
|
37
|
+
"context_strategy": params.context_strategy,
|
|
38
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Regime evaluation, reasoning, and warning generation.
|
|
3
|
+
|
|
4
|
+
Mirrors TypeScript analysis.ts exactly.
|
|
5
|
+
"""
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from .types import (
|
|
9
|
+
ReceiverProfile,
|
|
10
|
+
PlatformParameters,
|
|
11
|
+
RecommendInput,
|
|
12
|
+
PredictedRegime,
|
|
13
|
+
Confidence,
|
|
14
|
+
)
|
|
15
|
+
from .matching import OSCILLATION_THRESHOLD
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# ─── Regime evaluation ────────────────────────────────────────────────────────
|
|
19
|
+
|
|
20
|
+
def evaluate_regime(profile: ReceiverProfile) -> PredictedRegime:
|
|
21
|
+
"""
|
|
22
|
+
Evaluate predicted stability regime.
|
|
23
|
+
|
|
24
|
+
Boundary conditions from neurotypes.json:
|
|
25
|
+
- near_oscillation: TI >= 65 AND SG >= 55
|
|
26
|
+
- near_overload: TI <= 35 AND SG >= 65
|
|
27
|
+
- near_freeze: UE <= 35 AND FT >= 65
|
|
28
|
+
- stable: none of the above
|
|
29
|
+
"""
|
|
30
|
+
if profile.TI >= 65 and profile.SG >= 55:
|
|
31
|
+
return "near_oscillation"
|
|
32
|
+
if profile.TI <= 35 and profile.SG >= 65:
|
|
33
|
+
return "near_overload"
|
|
34
|
+
if profile.UE <= 35 and profile.FT >= 65:
|
|
35
|
+
return "near_freeze"
|
|
36
|
+
return "stable"
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# ─── Warning detection ────────────────────────────────────────────────────────
|
|
40
|
+
|
|
41
|
+
def generate_warnings(profile: ReceiverProfile, input_data: RecommendInput) -> list[str]:
|
|
42
|
+
warnings: list[str] = []
|
|
43
|
+
TI, SG, FT, UE, AR = profile.TI, profile.SG, profile.FT, profile.UE, profile.AR
|
|
44
|
+
|
|
45
|
+
sg_ti_product = SG * TI
|
|
46
|
+
if sg_ti_product > OSCILLATION_THRESHOLD:
|
|
47
|
+
warnings.append(
|
|
48
|
+
f"Oscillation risk: SG ({SG}) × TI ({TI}) = {sg_ti_product} exceeds the RPCS-1 "
|
|
49
|
+
f"oscillation threshold ({OSCILLATION_THRESHOLD}). Consider reducing SG or TI."
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
if SG >= 60 and FT <= 30 and TI <= 30:
|
|
53
|
+
warnings.append(
|
|
54
|
+
f"Overload risk: High SG ({SG}) + low FT ({FT}) + low TI ({TI}) — "
|
|
55
|
+
"agent may act on insufficient information. Raise FT or lower SG."
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
if UE <= 30 and FT >= 70:
|
|
59
|
+
warnings.append(
|
|
60
|
+
f"Freeze risk: Low UE ({UE}) + high FT ({FT}) — "
|
|
61
|
+
"agent may hedge endlessly without acting. Lower FT or raise UE."
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
env = input_data.environment
|
|
65
|
+
if env.stakes in ("high", "catastrophic") and AR >= 65:
|
|
66
|
+
warnings.append(
|
|
67
|
+
f"High stakes ({env.stakes}) + high AR ({AR}) — "
|
|
68
|
+
"aggressive ambiguity resolution in a high-stakes environment increases error risk."
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
if env.entropy == "chaotic" and env.context_relevance == "long":
|
|
72
|
+
warnings.append(
|
|
73
|
+
"Environment-context mismatch: chaotic entropy calls for short TI (Matching Principle), "
|
|
74
|
+
"but long context_relevance requests long integration. "
|
|
75
|
+
"This configuration is structurally near the oscillation boundary."
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
return warnings
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
# ─── Reasoning string ─────────────────────────────────────────────────────────
|
|
82
|
+
|
|
83
|
+
def _describe_level(value: float) -> str:
|
|
84
|
+
if value >= 70:
|
|
85
|
+
return "high"
|
|
86
|
+
if value >= 40:
|
|
87
|
+
return "moderate"
|
|
88
|
+
return "low"
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def generate_reasoning(
|
|
92
|
+
input_data: RecommendInput,
|
|
93
|
+
profile: ReceiverProfile,
|
|
94
|
+
params: PlatformParameters,
|
|
95
|
+
) -> str:
|
|
96
|
+
TI, SG, FT, UE, AR = profile.TI, profile.SG, profile.FT, profile.UE, profile.AR
|
|
97
|
+
env = input_data.environment
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
f"Environment analysis: {env.entropy} entropy → Matching Principle (Pred-09-5: TI ~ 1/H) "
|
|
101
|
+
f"yields TI = {TI} ({_describe_level(TI)} temporal integration window). "
|
|
102
|
+
f"{env.stakes} stakes drive SG = {SG} ({_describe_level(SG)} signal gain) and "
|
|
103
|
+
f"FT = {FT} ({_describe_level(FT)} filtering threshold) for basin stability. "
|
|
104
|
+
f"{env.commitment_style} commitment style sets AR = {AR}; "
|
|
105
|
+
f"{env.context_relevance} context relevance + entropy set UE = {UE}. "
|
|
106
|
+
f"Platform mapping: temperature = {params.temperature} (from SG via 1/SG relationship), "
|
|
107
|
+
f"max_tokens = {params.max_tokens} (from TI), "
|
|
108
|
+
f"context_strategy = {params.context_strategy}."
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
# ─── Principles applied ───────────────────────────────────────────────────────
|
|
113
|
+
|
|
114
|
+
def list_principles_applied(
|
|
115
|
+
input_data: RecommendInput, profile: ReceiverProfile
|
|
116
|
+
) -> list[str]:
|
|
117
|
+
principles = [
|
|
118
|
+
"Matching Principle (Pred-09-5): TI ~ 1/H",
|
|
119
|
+
"Basin Stability: minimize V(R,E) subject to task constraints",
|
|
120
|
+
"Boundary Avoidance: stay away from oscillation/overload/freeze regimes",
|
|
121
|
+
]
|
|
122
|
+
if profile.SG * profile.TI > OSCILLATION_THRESHOLD * 0.8:
|
|
123
|
+
principles.append(
|
|
124
|
+
"Oscillation Threshold (Paper 9 §oscillatory threshold): SG × TI < Δ_R"
|
|
125
|
+
)
|
|
126
|
+
if input_data.environment.stakes in ("high", "catastrophic"):
|
|
127
|
+
principles.append(
|
|
128
|
+
"Conservative Gating (high-stakes): raise FT, lower SG to prevent overload"
|
|
129
|
+
)
|
|
130
|
+
return principles
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
# ─── Confidence ───────────────────────────────────────────────────────────────
|
|
134
|
+
|
|
135
|
+
def assess_confidence(input_data: RecommendInput) -> Confidence:
|
|
136
|
+
score = 0
|
|
137
|
+
if input_data.task.domain:
|
|
138
|
+
score += 1
|
|
139
|
+
if input_data.task.expected_duration_per_call:
|
|
140
|
+
score += 1
|
|
141
|
+
score += 3 # all environment fields required
|
|
142
|
+
|
|
143
|
+
if score >= 4:
|
|
144
|
+
return "high"
|
|
145
|
+
if score >= 3:
|
|
146
|
+
return "medium"
|
|
147
|
+
return "low"
|