Skip to content

Add SDK support for enhanced task status#1864

Open
Uday-sidagana wants to merge 1 commit into
langflow-ai:mainfrom
Uday-sidagana:Jun-sdk-enhanced-task-status
Open

Add SDK support for enhanced task status#1864
Uday-sidagana wants to merge 1 commit into
langflow-ai:mainfrom
Uday-sidagana:Jun-sdk-enhanced-task-status

Conversation

@Uday-sidagana

@Uday-sidagana Uday-sidagana commented Jun 12, 2026

Copy link
Copy Markdown

Summary

Added SDK support for enhanced ingestion task status.

What changed

  • Added Python client.documents.get_task_status_enhanced(task_id).
  • Added Python client.documents.list_tasks_enhanced().
  • Added TypeScript client.documents.getTaskStatusEnhanced(taskId).
  • Added TypeScript client.documents.listTasksEnhanced().
  • Added TaskListResponse types.
  • Exported TypeScript task status types.
  • Added README examples.
  • Added SDK integration test coverage.

Note: no internal APIs are exposed.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added enhanced task status endpoints to both Python and TypeScript SDKs for retrieving detailed task information with structured failure metadata.
  • Documentation

    • Updated SDK READMEs with usage examples for new enhanced task status APIs.
  • Tests

    • Added integration test coverage for enhanced task status endpoints in both SDKs.

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This PR extends both the Python and TypeScript SDKs with enhanced task status endpoints. New TaskListResponse models and client methods (get_task_status_enhanced / getTaskStatusEnhanced and list_tasks_enhanced / listTasksEnhanced) enable retrieval of ingestion task data with structured failure metadata from dedicated enhanced API endpoints. Integration tests and documentation examples demonstrate usage.

Changes

Enhanced Task Status Endpoints

Layer / File(s) Summary
Python SDK: Enhanced task methods and models
sdks/python/openrag_sdk/models.py, sdks/python/openrag_sdk/documents.py, sdks/python/openrag_sdk/__init__.py
New TaskListResponse Pydantic model added. DocumentsClient adds get_task_status_enhanced(task_id) and list_tasks_enhanced() async methods that call /api/v1/tasks/.../enhanced endpoints. Methods exported via __all__.
TypeScript SDK: Enhanced task methods and models
sdks/typescript/src/types.ts, sdks/typescript/src/documents.ts, sdks/typescript/src/index.ts
New TaskListResponse TypeScript interface added. DocumentsClient adds getTaskStatusEnhanced(taskId) and listTasksEnhanced() methods with a centralized parseTaskStatus helper that casts raw endpoint responses to IngestTaskStatus. Types re-exported from package entrypoint.
Integration tests
tests/integration/sdk/test_documents.py, sdks/typescript/tests/integration.test.ts
Python and TypeScript integration tests verify enhanced task endpoints return expected response shapes: status field in enhanced status objects and tasks array in task list responses.
Documentation
sdks/python/README.md, sdks/typescript/README.md
README examples show calling enhanced task methods to retrieve task status and list tasks with structured failure metadata.

Possibly related PRs

  • langflow-ai/openrag#1671: Introduces backend /v1/tasks/.../enhanced endpoints with enriched failure metadata that these SDK methods consume.

Suggested labels

enhancement, tests

Suggested reviewers

  • mpawlow
  • zzzming
  • edwinjosechittilappilly

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add SDK support for enhanced task status' clearly and accurately summarizes the main change across both Python and TypeScript SDKs.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 2

🧹 Nitpick comments (2)
sdks/python/openrag_sdk/__init__.py (1)

97-97: ⚡ Quick win

Export IngestTaskStatus alongside TaskListResponse from the root package API.

TaskListResponse.tasks and document status methods revolve around IngestTaskStatus; exporting only TaskListResponse forces deep imports for a core type.

Suggested change
 from .models import (
@@
     IngestResponse,
+    IngestTaskStatus,
@@
 __all__ = [
@@
     "IngestResponse",
+    "IngestTaskStatus",
     "TaskListResponse",
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@sdks/python/openrag_sdk/__init__.py` at line 97, Add IngestTaskStatus to the
root package exports so consumers can import it without deep imports; update the
export list that currently contains "TaskListResponse" (in
sdks/python/openrag_sdk/__init__.py) to also include "IngestTaskStatus" so both
TaskListResponse and IngestTaskStatus are exposed from the package root.
sdks/python/openrag_sdk/models.py (1)

95-95: ⚡ Quick win

Default tasks to an empty list for cross-SDK response parity.

TaskListResponse currently requires tasks, while sdks/typescript/src/documents.ts (Lines 131-133) gracefully defaults missing tasks to []. The same payload can parse in TypeScript but fail in Python with a validation error; aligning defaults avoids SDK behavior drift.

Suggested change
 class TaskListResponse(BaseModel):
     """Response from listing ingestion tasks."""
 
-    tasks: list[IngestTaskStatus]
+    tasks: list[IngestTaskStatus] = Field(default_factory=list)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@sdks/python/openrag_sdk/models.py` at line 95, In TaskListResponse in
models.py, make the tasks field default to an empty list for parity with
TypeScript: replace the required tasks: list[IngestTaskStatus] with a
pydantic-safe default (use Field(default_factory=list)) so missing tasks in
responses parse as [] rather than erroring; import Field from pydantic if not
present and keep the element type as IngestTaskStatus.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@sdks/typescript/src/documents.ts`:
- Around line 131-133: The code maps data.tasks without ensuring it's an array,
which can throw if the API returns a non-array; update the tasks assignment in
the relevant method in documents.ts to guard with Array.isArray(data.tasks) and
only map when true, otherwise default to an empty array (or preserve expected
fallback), calling this.parseTaskStatus for each item; reference the data.tasks
field and this.parseTaskStatus to locate and update the logic.

In `@tests/integration/sdk/test_documents.py`:
- Around line 119-125: The enhanced integration test is under-asserting contract
fidelity: update tests in tests/integration/sdk/test_documents.py to verify
enhanced metadata by asserting that enhanced_status.files is present and
non-empty and that the created task (task_response.task_id) appears in the
enhanced_tasks.tasks listing (e.g., at least one entry has matching task_id);
specifically add assertions after calling
client.documents.get_task_status_enhanced and
client.documents.list_tasks_enhanced to check enhanced_status.files (or
equivalent files field) exists and contains expected file entries and that any
task in enhanced_tasks.tasks has task_id == task_response.task_id to ensure the
created task is included.

---

Nitpick comments:
In `@sdks/python/openrag_sdk/__init__.py`:
- Line 97: Add IngestTaskStatus to the root package exports so consumers can
import it without deep imports; update the export list that currently contains
"TaskListResponse" (in sdks/python/openrag_sdk/__init__.py) to also include
"IngestTaskStatus" so both TaskListResponse and IngestTaskStatus are exposed
from the package root.

In `@sdks/python/openrag_sdk/models.py`:
- Line 95: In TaskListResponse in models.py, make the tasks field default to an
empty list for parity with TypeScript: replace the required tasks:
list[IngestTaskStatus] with a pydantic-safe default (use
Field(default_factory=list)) so missing tasks in responses parse as [] rather
than erroring; import Field from pydantic if not present and keep the element
type as IngestTaskStatus.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dda83fe6-62f2-41aa-a722-7e18b9096bca

📥 Commits

Reviewing files that changed from the base of the PR and between 88d569c and bd83843.

📒 Files selected for processing (10)
  • sdks/python/README.md
  • sdks/python/openrag_sdk/__init__.py
  • sdks/python/openrag_sdk/documents.py
  • sdks/python/openrag_sdk/models.py
  • sdks/typescript/README.md
  • sdks/typescript/src/documents.ts
  • sdks/typescript/src/index.ts
  • sdks/typescript/src/types.ts
  • sdks/typescript/tests/integration.test.ts
  • tests/integration/sdk/test_documents.py

Comment on lines +131 to +133
tasks: (data.tasks ?? []).map((task: Record<string, unknown>) =>
this.parseTaskStatus(task)
),

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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Guard data.tasks with Array.isArray before calling .map().

If the API returns a non-array truthy value for tasks, this will throw at runtime. A narrow shape guard keeps the method resilient.

Suggested change
   async listTasksEnhanced(): Promise<TaskListResponse> {
     const response = await this.client._request("GET", "/api/v1/tasks/enhanced");
     const data = await response.json();
+    const tasksRaw = Array.isArray(data.tasks) ? data.tasks : [];
     return {
-      tasks: (data.tasks ?? []).map((task: Record<string, unknown>) =>
+      tasks: tasksRaw.map((task: Record<string, unknown>) =>
         this.parseTaskStatus(task)
       ),
     };
   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
tasks: (data.tasks ?? []).map((task: Record<string, unknown>) =>
this.parseTaskStatus(task)
),
async listTasksEnhanced(): Promise<TaskListResponse> {
const response = await this.client._request("GET", "/api/v1/tasks/enhanced");
const data = await response.json();
const tasksRaw = Array.isArray(data.tasks) ? data.tasks : [];
return {
tasks: tasksRaw.map((task: Record<string, unknown>) =>
this.parseTaskStatus(task)
),
};
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@sdks/typescript/src/documents.ts` around lines 131 - 133, The code maps
data.tasks without ensuring it's an array, which can throw if the API returns a
non-array; update the tasks assignment in the relevant method in documents.ts to
guard with Array.isArray(data.tasks) and only map when true, otherwise default
to an empty array (or preserve expected fallback), calling this.parseTaskStatus
for each item; reference the data.tasks field and this.parseTaskStatus to locate
and update the logic.

Comment on lines +119 to +125
enhanced_status = await client.documents.get_task_status_enhanced(
task_response.task_id
)
assert enhanced_status.status is not None

enhanced_tasks = await client.documents.list_tasks_enhanced()
assert isinstance(enhanced_tasks.tasks, list)

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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Shared root cause: enhanced integration tests are under-asserting contract fidelity in tests/integration/sdk/test_documents.py and sdks/typescript/tests/integration.test.ts.
Both tests only verify basic shape (status defined / tasks is array), so they can pass even when enhanced metadata regresses. Tighten both to assert enhanced files presence and that the created task appears in enhanced task listings.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/integration/sdk/test_documents.py` around lines 119 - 125, The enhanced
integration test is under-asserting contract fidelity: update tests in
tests/integration/sdk/test_documents.py to verify enhanced metadata by asserting
that enhanced_status.files is present and non-empty and that the created task
(task_response.task_id) appears in the enhanced_tasks.tasks listing (e.g., at
least one entry has matching task_id); specifically add assertions after calling
client.documents.get_task_status_enhanced and
client.documents.list_tasks_enhanced to check enhanced_status.files (or
equivalent files field) exists and contains expected file entries and that any
task in enhanced_tasks.tasks has task_id == task_response.task_id to ensure the
created task is included.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant