Spaces:
Sleeping

File size: 3,010 Bytes
f45a595
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Verification record

Tested in the Arena sandbox on **2026-10-07** (Asia/Calcutta).

## Final results

| Layer | Result |
|---|---|
| Static Python compilation | passed |
| Ruff critical checks (`E4,E7,E9,F,I`) on the new API/adapter/tests/scripts | passed |
| Combined offline suite | **114 passed, 6 live-only skipped** |
| Original Upstage live suite | **6/6 passed** |
| Running-server smoke test | all checks passed |
| Repeated ZCode coding-agent probe | **5/5 complete two-tool loops passed** |
| OpenAI Python SDK probe | models, JSON chat, SSE+usage, and function call passed |
| Secret/cache scan | no credential cache, `.env`, PEM, or old-provider reference included |

## Live Upstage coverage

The copied source suite passed live checks for:

1. connection and short chat;
2. typed realtime streaming;
3. web-search sources;
4. multi-turn history;
5. fresh Next.js credential capture; and
6. reasoning/content separation with no `<think>` leakage.

## Running API coverage

`smoke_test.py` passed against native Uvicorn on port 7860:

- `/healthz`;
- four-model discovery;
- non-streaming Chat Completions;
- realtime SSE and `[DONE]`;
- streamed usage;
- a required OpenAI function call; and
- a follow-up turn containing an assistant `tool_calls` message and `role: tool` result.

`live_zcode_test.py` was then run five consecutive times. Every run completed this two-step `tool_choice: auto` workflow:

1. Solar selected `read_file` for `README.md`.
2. The synthetic file result was returned as an OpenAI tool message.
3. Solar selected `write_file` with schema-valid `path` and `content` arguments.

The repeated run exposed occasional Solar narration instead of a structured call during development. The final adapter now detects that failure mode, performs one strict JSON retry, applies bounded repair only to tool-shaped JSON, validates the selected name and arguments against the caller's schema, and never exposes the narration as a tool call. The five-run verification passed after that fix.

## OpenAI SDK coverage

Using the official `openai` Python package with:

```python
OpenAI(base_url="http://127.0.0.1:7860/v1", api_key="public")
```

all of the following passed live:

- `client.models.list()`;
- non-streaming `client.chat.completions.create(...)`;
- streaming chunks plus the usage-only chunk; and
- `tools` + `tool_choice="required"` returning a parsed SDK `tool_calls` object.

## Container note

Docker/Podman is unavailable in this sandbox, so the image itself could not be executed here. The Dockerfile was reviewed statically and follows Hugging Face Docker Space conventions: `sdk: docker`, port `7860`, `0.0.0.0`, a health check, and non-root UID 1000. The exact application and pinned runtime dependencies were exercised natively.

## Re-run

```bash
pytest -q
UPSTAGE_LIVE=1 pytest -q tests/test_upstage_provider.py -k Live
uvicorn app:app --host 0.0.0.0 --port 7860
python smoke_test.py http://127.0.0.1:7860
python live_zcode_test.py http://127.0.0.1:7860
```