Skip to content

[ML-896] docs: align docs with implementation#72

Open
kxzk wants to merge 1 commit intomainfrom
feature/ml-896-docs-align-docs-with-implementation
Open

[ML-896] docs: align docs with implementation#72
kxzk wants to merge 1 commit intomainfrom
feature/ml-896-docs-align-docs-with-implementation

Conversation

@kxzk
Copy link
Copy Markdown
Collaborator

@kxzk kxzk commented Mar 30, 2026

TL;DR

Align docs with actual SDK behavior for SWR activation and prompt APIs.

Why

docs/ claimed SWR behavior was controlled by cache_stale_while_revalidate, but runtime behavior is activated by cache_stale_ttl > 0. API reference also omitted public prompt write APIs and under-specified fallback/config types.

Checklist

  • Has label
  • Has linked issue
  • Tests added for new behavior
  • Docs updated (if user-facing)

Closes ML-896

Summary

  • Updated docs/CONFIGURATION.md to describe SWR runtime behavior correctly (cache_stale_ttl > 0 controls activation).
  • Updated docs/API_REFERENCE.md to:
    • Add Client#create_prompt and Client#update_prompt.
    • Correct get_prompt fallback type (String or Array<Hash>).
    • Correct cache_stale_ttl type to include :indefinite.

Fixes addressed

  • Misleading SWR toggle semantics in docs.
  • Missing public prompt write methods in API reference.
  • Incomplete parameter/type coverage in API reference.

Validation checklist

  • Langfuse CLI schema/API discovery check (npx langfuse-cli api __schema)
  • bundle exec rspec (blocked by local bundler mismatch)
  • bundle exec rubocop (blocked by local bundler mismatch)

Open with Devin

Copilot AI review requested due to automatic review settings March 30, 2026 13:07
@linear
Copy link
Copy Markdown

linear bot commented Mar 30, 2026

Copy link
Copy Markdown

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@kxzk kxzk added the documentation Improvements or additions to documentation label Mar 30, 2026
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Aligns the documentation under docs/ with the Ruby SDK’s actual behavior for stale-while-revalidate (SWR) caching and prompt management APIs, so that configuration and API reference match what the runtime supports.

Changes:

  • Clarifies SWR activation semantics: runtime SWR is active when cache_stale_ttl > 0, not solely via cache_stale_while_revalidate.
  • Expands API reference to include Client#create_prompt and Client#update_prompt.
  • Corrects/extends type documentation for get_prompt fallback and cache_stale_ttl (including :indefinite).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
docs/CONFIGURATION.md Updates SWR documentation and test snippet to reflect cache_stale_ttl-based activation.
docs/API_REFERENCE.md Adds prompt write APIs and corrects several parameter/type definitions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


- `false` (default): Cache expires at TTL, next request waits for API (~100ms)
- `true`: After TTL, serves stale data instantly (~1ms) + refreshes in background
- `cache_stale_ttl <= 0` (default): Cache expires at TTL, next request waits for API (~100ms)
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

Docs state cache_stale_ttl <= 0 disables SWR, but cache_stale_ttl is validated as non-negative in runtime config (negative values raise ConfigurationError). Consider documenting the disabled case as cache_stale_ttl == 0 (default) to avoid implying negative values are supported.

Suggested change
- `cache_stale_ttl <= 0` (default): Cache expires at TTL, next request waits for API (~100ms)
- `cache_stale_ttl == 0` (default): Cache expires at TTL, next request waits for API (~100ms)

Copilot uses AI. Check for mistakes.
Comment on lines +124 to 131
- **Description:** Advisory SWR intent flag (effective SWR behavior is controlled by `cache_stale_ttl`)

```ruby
config.cache_stale_while_revalidate = true # Enable SWR
config.cache_stale_while_revalidate = true # Optional intent flag
```

When enabled, serves stale cached data immediately while refreshing in the background. This dramatically reduces P99 latency by avoiding synchronous API waits after cache expiration.
This flag does not independently turn SWR on/off in runtime cache behavior. SWR is active when `cache_stale_ttl > 0`.

Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

This section clarifies SWR activation depends on cache_stale_ttl > 0, but later in this document the Production example still suggests cache_stale_while_revalidate = true “Enable SWR” without setting cache_stale_ttl. Please update the examples/comments below to match the new semantics (e.g., set cache_stale_ttl in the Production snippet or adjust the wording).

Copilot uses AI. Check for mistakes.
Comment on lines +310 to +315
**Raises:**

- `NotFoundError` if the prompt version does not exist
- `UnauthorizedError` if authentication fails
- `ApiError` for other API errors

Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

Client#update_prompt can raise ArgumentError when labels is not an Array (enforced in ApiClient#update_prompt). Please document this in the Raises section so callers know what to expect for invalid inputs.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants