Skip to content

Feature/v0.4.0/structured output - #49

Merged
mavdol merged 10 commits into
mainfrom
feature/v0.4.0/structured-output
Jan 24, 2026
Merged

mavdol merged 10 commits into
mainfrom
feature/v0.4.0/structured-output

Conversation

@mavdol

@mavdol mavdol commented Jan 23, 2026

Copy link
Copy Markdown
Member

Summary

This PR introduces significant improvements to task execution and observability:

1. Structured Task Response Envelope

Tasks now return a detailed JSON envelope containing execution metadata alongside results. This provides better visibility into task performance and error handling.

Example:

@task(name="data_processor")
async def process_data():
    return {"status": "processed", "count": 42}

@task(name="main")
async def main():
    response = await process_data()
    return response

Response format:

{
  "success": true,
  "result": {
    "status": "processed",
    "count": 42
  },
  "error": null,
  "execution": {
    "task_name": "data_processor",
    "duration_ms": 1523,
    "retries": 0,
    "fuel_consumed": 45000
  }
}

Fields:

  • success: Boolean indicating task completion status
  • result: The actual return value from the task (only present on success)
  • error: Error details if the task failed (type and message)
  • execution: Metadata about the task execution (name, duration, retry count, fuel consumption)

2. Enhanced Logging with --verbose

Improved error messages with consistent formatting for better debugging:

[test_async_timeout] timeout after 5000ms
[test_immediate_fuel_exhaustion] fuel exhausted during execution
[test_ram_limit] memory limit exceeded: minimum 202 pages required
[my_task] execution failed: division by zero

Error categories:

  • Timeout errors: Clear indication when tasks exceed time limits
  • Resource exhaustion: Memory and fuel limit violations
  • Execution errors: Runtime errors with descriptive messages

⚠️ Breaking Changes: Task return values are now wrapped in the JSON envelope structure. Existing code may need to access response.result instead of using response directly.

@mavdol
mavdol merged commit 421ae9c into main Jan 24, 2026
2 checks passed
@mavdol
mavdol deleted the feature/v0.4.0/structured-output branch January 24, 2026 12:12
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