-
Notifications
You must be signed in to change notification settings - Fork 1
Multi-provider model auto-discovery and cost-based auto-optimization #746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6a7e38e
70fc9d8
574fa8c
a42b7b6
77c2186
0ad4193
49002cc
9b66a13
806bda5
c3027c1
2aeab27
0f37a76
5163030
b67c051
0263ad5
afe0956
3d42c8d
877c77f
8d629f4
895eb22
4bd9c2b
1b7dbd2
3781930
b65711f
6b6edba
c09cac0
2a4270a
125bfc1
32ba3a9
c138d17
ddd0591
bbb6361
ab0c05c
fccac33
54dfce2
21a17f0
13fe555
a107892
8394373
da24b1a
583c4f3
c1c7997
216177f
56d3085
8fee52b
5b49594
1ffdc3f
ea254c2
2e76caa
ea4dfa9
46725e2
c7b5dbc
79ce905
4af8e26
f7b2079
17d636b
b7ee4bb
becc758
a1d8128
fe7b632
8a88063
5ea0f77
d3ed441
a159dff
4d8cd86
998c86f
fb16482
76de3e1
51ac452
ec94d99
7cb34a9
c646ba5
5d80e11
454b9f5
b81f8d7
173288c
f7141ea
361725b
d3abf51
8aaa0e0
823ce91
c5e0286
4b954e4
73c6c98
e59ef71
a29ff9e
1eef1e9
9bc620d
0f61128
78894f6
d82e592
9b6dec3
d8c1b73
a0a354a
618810e
db45804
f8cac36
6422a20
18d8c3b
e0000ad
c518049
c2bb2b2
2f904a2
bd4c1a3
fe8437d
bcb55d0
c860644
273943e
b782b01
a7de9f6
96501bb
910d9ef
9d4562f
435c3ef
153ca6b
fa20fe3
2f42a1b
d83a029
d1f97a2
c460270
36b3d2a
cc0d295
54ef9bb
237ba2d
01aafd5
f783e95
bb88bf7
7f47665
c722fa8
f3d54b1
af500ee
cb88960
1614c7f
adc4f80
67ed128
e5180c3
490dfd8
0df4267
cc413a4
f6456e1
8ecd379
3f33a72
2816140
d3480cc
6373d98
63451a0
6354c04
62100d3
bd2515f
b36878c
52e0746
29e1388
b30697d
160471b
a5f7697
7cfad1b
d00431e
4465922
da849d3
27aa4ad
b2b3d8e
d1bc819
8bf757f
8194e04
383ccfd
50b91c3
792c9ce
b72a838
e99b097
abfb45a
9f45226
eaf7ff3
bad1e1a
a07c11f
19c3e88
4923447
a9278d1
c0c2ecb
73853a4
3ab44dd
474b667
1d3e062
1b22ff0
bc882c0
0fb8fdb
f0f30f3
3bc1264
8f922d8
1c5b5c8
9f662c4
070d929
53f47a6
dac931f
229bb30
f15ccb0
c6f30eb
228126b
cdca9d8
018f6ef
c580839
61f94a0
c179b54
ccfa292
15a16d8
06dfa40
b1dc49e
87e1c3b
df5f5bf
a9cd011
71164ae
a139ece
1c05e20
bd78ca1
ebc76d4
719d9cc
e9935d7
aeae379
efc4b5f
1003cea
40b7bac
2e36f9b
491566e
887cc66
cdfc15d
fcb82a1
3a59b67
007acf6
0b19112
60d9cfc
9058a08
e3e9788
621c42f
d7133c4
64b6d56
e0413fe
68002d0
d5236bb
de4d95a
2acb3a4
775ea13
badcf28
6a411be
d2072fa
63d9abf
83b17bd
a1d486a
785d125
3cf72d5
7771d99
c196e29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| project_slug: contextual-orchestrator | ||
| owner: ContextualWisdomLab | ||
| default_status: proposed | ||
| decision_id_format: NNNN | ||
| template_source: madr-v4 | ||
| last_decision_id: 0009 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,8 +71,19 @@ push or open a PR. | |
| - Its `ModelClient` currently reads `os.environ.get(agent.api_key_env)` — this | ||
| is the KV-principle deviation above. Resolve the API key (including the org | ||
| `OPENAI_API_KEY`) from the **KV / credential registry**, not env. | ||
| - The **OpenCode review pipeline is separate** and stays on **GitHub Models** — | ||
| do not change it. | ||
| - **Policy change (2026-08-18, explicit org decision, supersedes the prior | ||
| "stays on GitHub Models" rule):** OpenCode, Noema, and Strix — the org's | ||
| three-stage CI review pipeline defined in `ContextualWisdomLab/.github` | ||
| (`opencode.jsonc`, `noema-review.yml`, `strix.yml`) — are being migrated to | ||
| use `contextual-orchestrator` as their shared backend, with | ||
| `BYTEZ_API_KEY`, `NVIDIA_NIM_API_KEY`, `NVIDIA_NIM_API_KEY_SUB`, | ||
| `OPENROUTER_API_KEY`, and `OPENAI_API_KEY` registered in this repo's KV so | ||
| it auto-discovers models across all five and auto-optimizes routing by | ||
| cost (see `contextual_orchestrator/model_discovery.py`, the | ||
| `discover-models` CLI subcommand, and `ModelAgent.auth_scheme` for | ||
| non-Bearer providers like Bytez). The provider-config change to the org | ||
| repo itself lands as a separate, human-reviewed PR — this repo does not | ||
| push or merge it automatically. | ||
|
Comment on lines
+74
to
+86
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win 주변의 오래된 KV 편차 설명을 함께 갱신하십시오. 새 정책 항목은 정확합니다. 그러나 같은 절의 앞부분은 아직 " 🤖 Prompt for AI Agents |
||
|
|
||
| ### This repo's role in the ecosystem | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,10 +2,11 @@ | |||||||||||||||||||||||||||||||
| # tree on a slim Python base. Runs the OpenAI-compatible server. | ||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||
| # Build: docker build -t contextual-orchestrator . | ||||||||||||||||||||||||||||||||
| # Run : docker run --rm -p 8000:8000 \ | ||||||||||||||||||||||||||||||||
| # -e CONTEXTUAL_ORCHESTRATOR_TOKEN=change-me \ | ||||||||||||||||||||||||||||||||
| # -e OPENAI_API_KEY=sk-... \ | ||||||||||||||||||||||||||||||||
| # contextual-orchestrator | ||||||||||||||||||||||||||||||||
| # Run : seed CONTEXTUAL_ORCHESTRATOR_TOKEN and provider credentials into the KV | ||||||||||||||||||||||||||||||||
| # registry first, then use: | ||||||||||||||||||||||||||||||||
| # docker run --rm -p 8000:8000 contextual-orchestrator | ||||||||||||||||||||||||||||||||
| # Runtime secrets are never passed through the container environment or argv; | ||||||||||||||||||||||||||||||||
| # see docs/kv-credentials.md for the bootstrap flow. | ||||||||||||||||||||||||||||||||
|
Comment on lines
+5
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win 실행 예시에 KV 백엔드 연결 방법이 없습니다. 기본 credential 백엔드는 프로세스 로컬 in-memory 백엔드입니다. 컨테이너는 새 프로세스로 시작하므로 그 백엔드에는 📝 제안 수정-# Run : seed CONTEXTUAL_ORCHESTRATOR_TOKEN and provider credentials into the KV
-# registry first, then use:
-# docker run --rm -p 8000:8000 contextual-orchestrator
+# Run : seed CONTEXTUAL_ORCHESTRATOR_TOKEN and provider credentials into the KV
+# registry first, then point the container at that same KV:
+# docker run --rm -p 8000:8000 \
+# -e CONTEXTUAL_ORCHESTRATOR_KV_BACKEND=postgres \
+# -e CONTEXTUAL_ORCHESTRATOR_KV_DSN=... \
+# -e CONTEXTUAL_ORCHESTRATOR_KV_PASSPHRASE=... \
+# contextual-orchestrator
+# These variables only open the KV; they are not provider or auth secrets.
# Runtime secrets are never passed through the container environment or argv;
# see docs/kv-credentials.md for the bootstrap flow.📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
| # Agents: defaults to the bundled mock pool; mount your own and set AGENTS_FILE: | ||||||||||||||||||||||||||||||||
| # -v ./agents.json:/app/agents.json -e AGENTS_FILE=/app/agents.json | ||||||||||||||||||||||||||||||||
| # python:3.12-slim | ||||||||||||||||||||||||||||||||
|
|
@@ -26,4 +27,4 @@ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s \ | |||||||||||||||||||||||||||||||
| CMD ["python", "-c", "import urllib.request,os;urllib.request.urlopen(f'http://127.0.0.1:{os.environ.get(\"PORT\",\"8000\")}/healthz', timeout=2)"] | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # --allow-public-bind: 컨테이너 내부 0.0.0.0 바인딩 필요(외부 노출은 호스트 포트 매핑이 결정) | ||||||||||||||||||||||||||||||||
| CMD ["sh", "-c", "python -m contextual_orchestrator --serve --agents \"$AGENTS_FILE\" --host 0.0.0.0 --port \"$PORT\" --allow-public-bind"] | ||||||||||||||||||||||||||||||||
| CMD ["sh", "-c", "python -m contextual_orchestrator --serve --agents \"$AGENTS_FILE\" --host 0.0.0.0 --port \"$PORT\" --allow-public-bind --auth-token-key CONTEXTUAL_ORCHESTRATOR_TOKEN"] | ||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
provider 모델 목록 parser의 Atheris 실행 대상을 추가하십시오.
exercise_provider_model_payload()는 Hypothesis 테스트에서만 호출됩니다. 이 coverage-guided 작업은 해당 대상을 호출하는 Atheris harness를 실행하지 않습니다. 원격 provider 응답은 비신뢰 입력입니다.fuzz/fuzz_provider_model_payload.py를 추가하고 이 작업에서 실행하십시오.As per coding guidelines:
untrusted-input parsers ... share invariant checks in fuzz/targets.py, driven by both Hypothesis (tests/fuzz/) and Atheris (fuzz/).🤖 Prompt for AI Agents
Source: Coding guidelines