Skip to content

feat(transcribe): add optional Atlas Cloud provider - #71

Open
binyangzhu000-sudo wants to merge 1 commit into
ChatAndBuild:mainfrom
binyangzhu000-sudo:codex/add-atlas-transcription
Open

binyangzhu000-sudo wants to merge 1 commit into
ChatAndBuild:mainfrom
binyangzhu000-sudo:codex/add-atlas-transcription

Conversation

@binyangzhu000-sudo

Copy link
Copy Markdown

Summary

  • keep OpenAI as the default transcription provider and add Atlas Cloud as an explicit opt-in
  • map local audio to the live xai/stt-v1 schema, including optional diarization
  • submit Atlas jobs once and poll prediction status with bounded exponential backoff
  • document provider-specific keys, capabilities, and unsupported options

Testing

  • python3 -m py_compile skills/transcribe/scripts/transcribe_diarize.py
  • OpenAI default dry-run and Atlas diarized dry-run
  • focused mock harness confirming one POST, bounded GET polling, and text/JSON formatting
  • workflow-equivalent frontmatter, category, injection-pattern, and length checks

No paid transcription request was sent; the integration was validated against the live Atlas model catalog and OpenAPI schema plus local request/response mocks.

Signed-off-by: binyangzhu000-sudo <224954946+binyangzhu000-sudo@users.noreply.github.com>
@greptile-apps

greptile-apps Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This change adds an opt-in Atlas Cloud transcription path with Base64 audio submission and asynchronous prediction polling. Offline execution reproduced two reliability failures in skills/transcribe/scripts/transcribe_diarize.py: supported large audio files create several simultaneous in-memory representations before submission, and polling can issue a prediction request after its configured timeout has elapsed. The change should not merge until the large-input memory behavior is addressed.

Confidence Score: 4/5

The Atlas transcription implementation is not safe to merge as written because a documented supported input size can exhaust the invoking process's memory.

Focused offline executions exercised the production payload, serialization, and polling paths. They measured the duplicated audio representations and reproduced a request occurring after the polling deadline.

Files Needing Attention: skills/transcribe/scripts/transcribe_diarize.py needs changes to avoid retaining multiple full-size audio representations and to prevent polling requests after the deadline.

T-Rex T-Rex Logs

What T-Rex did

  • Ran the offline Atlas audio payload serialization probe and executed both the Base64-omitted control path and the encoded serialization path to validate the P1 finding.
  • Executed the focused offline Atlas polling boundary test, reproduced the boundary output, and confirmed Python compilation for the test source.
  • Validated the Atlas audio serialization probe contract by inspecting the authored probe script and reviewing the before- and after-path outputs.
  • Ran the atlas_poll_deadline_boundary_test and performed a Python compile check for the related scripts to verify the deadline boundary behavior and script syntax.

View all artifacts

T-Rex Ran code and verified through T-Rex

Comments Outside Diff (2)

  1. General comment

    P1 Atlas payload construction duplicates large audio representations in memory

    • Bug
      • For inputs allowed up to 500 MiB, _build_atlas_payload reads the whole file then Base64-encodes it into a Python string; _atlas_json_request then creates and retains a separate UTF-8 JSON bytes body. The executed 64 MiB sparse control/encoded pair shows an 85.33 MiB Base64 string and 85.33 MiB request body, with 256.00 MiB traced peak (4.00× the input) and 170.67 MiB retained after serialization. This supports a severe memory-pressure/OOM consequence at the 500 MiB limit.
    • Cause
      • audio_path.read_bytes() creates a complete binary buffer, base64.b64encode(...).decode('ascii') materializes Base64 bytes then a text string, and json.dumps(payload).encode('utf-8') materializes the serialized request bytes while the payload remains referenced.
    • Fix
      • Avoid inline Base64 JSON for large audio: use a streaming/multipart upload or a provider upload/reference flow. If inline JSON is unavoidable, enforce a substantially lower safe limit and minimize simultaneous representations.

    T-Rex Ran code and verified through T-Rex

  2. General comment

    P2 Atlas polling issues a GET after its polling deadline

    • Bug
      • For a pending Atlas prediction, a sleep can cross the deadline and the implementation still invokes the prediction GET before the loop condition is evaluated again. The focused injected-clock run set the deadline to 2.0 seconds, advanced the clock to 3.0 during sleep, and recorded the GET at 3.0 before receiving the timeout error.
    • Cause
      • _run_atlas_one evaluates monotonic() < deadline only at the start of the while body (line 294). It sleeps at line 295 and performs request_json(..., "GET", ...) at lines 296-298 without checking whether that sleep exhausted the deadline.
    • Fix
      • Re-check monotonic() < deadline immediately after sleep and before the GET, or cap sleep duration to remaining deadline time and exit when no time remains.

    T-Rex Ran code and verified through T-Rex

Reviews (1): Last reviewed commit: "feat(transcribe): add optional Atlas Clo..." | Re-trigger Greptile

Comment on lines +198 to +202
"audio": (
base64.b64encode(audio_path.read_bytes()).decode("ascii")
if encode_audio
else "<base64 audio omitted>"
),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Large Atlas inputs exhaust memory

Atlas accepts audio files up to 500 MB, but this path reads the entire file into memory, materializes a Base64 string, and then serializes that string into a separate JSON byte buffer. The exercised 64 MiB input reached a 256 MiB traced allocation peak; at the documented limit this can require roughly 2 GiB of process memory before the request is sent, causing avoidable memory pressure or termination. Use an upload/reference flow or streaming transport, or lower the accepted size to one that is safe for the simultaneous representations.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Artifacts

Offline Atlas audio payload and serialization probe source

  • The authored executable invokes the real payload and request-serialization functions against a sparse audio file with an offline HTTP capture, showing the measured representations.

Control run with Base64 audio omitted

  • The executed 64 MiB sparse-file control captured a 58-byte request and negligible traced allocation, establishing the non-encoded baseline.

Encoded Atlas audio serialization run

  • The executed 64 MiB sparse-file encoded run captured an 85.33 MiB Base64 payload and JSON body with a 256.00 MiB traced peak, supporting the memory-pressure finding.

View artifacts

T-Rex Ran code and verified through T-Rex

Comment on lines +294 to +298
while monotonic() < deadline:
sleep(poll_interval)
prediction = _atlas_data(
request_json(prediction_url, "GET", api_key, None)
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Polling exceeds its deadline

A polling sleep can cross the deadline, but the code issues the prediction GET before evaluating the loop condition again. The deadline-boundary run advanced the injected clock from 0 to 3 seconds during the first sleep for a 2-second timeout and recorded a GET at time 3 before the timeout was raised. Re-check the deadline after sleeping and before requesting the prediction, or cap the sleep interval to the remaining time.

Artifacts

Focused offline Atlas polling deadline boundary test source

  • The exact authored Python test injects a clock, sleep function, and Atlas request function to cross the deadline during polling, demonstrating the boundary condition.

Atlas polling boundary reproduction output

  • The executed offline test records a GET at simulated time 3.0 after a 2.0-second deadline and then records the timeout error, proving the extra request occurs.

Python compilation validation output

  • The executed byte-compilation command exits successfully for both the focused test and the target transcription module, confirming they are syntactically executable.

Captured exact Atlas polling boundary test source

  • The executed source capture prints the complete authored test file used for the offline reproduction, preserving the exact injected test setup.

View artifacts

T-Rex Ran code and verified through T-Rex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant