> For the complete documentation index, see [llms.txt](https://docs.algenta.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.algenta.ai/sdks/python/decisions-and-products.md).

# Decisions & products

These methods record decisions in [decision memory](/concepts/decision-memory.md) and drive product-level intelligence (decision, optimize, retrieve, forecast). They are available on both `AlgentaClient` and `AsyncAlgentaClient` (await the async calls). The product methods take a request dict; the decision-memory methods take a decision id plus typed keyword arguments.

## Method reference

| Method                                                                                                                   | Purpose                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `product_decision(request)`                                                                                              | Make a product-level decision (`ProductDecisionResult`). Posts to `/v1/decision`.                                                          |
| `product_agent_run(request)`                                                                                             | Run a product agent workflow (`ProductAgentRunResult`). Posts to `/v1/agent/run`.                                                          |
| `product_optimize(request)`                                                                                              | Optimize a product objective (`ProductOptimizeResult`). Posts to `/v1/optimize`.                                                           |
| `product_retrieve(request)`                                                                                              | Retrieve ranked product results for a query (`ProductRetrieveResult`). Posts to `/v1/retrieve`.                                            |
| `product_forecast(request)`                                                                                              | Forecast product metrics over future periods (`ProductForecastResult`). Posts to `/v1/forecast`.                                           |
| `log_decision(request)`                                                                                                  | Record a decision in decision memory (`DecisionLogResult`). Posts to `/v1/decisions`.                                                      |
| `list_decisions(*, page=None, limit=None, page_size=None, with_outcome_only=None)`                                       | List recorded decisions (`DecisionListResult`). Reads `/v1/decisions`.                                                                     |
| `get_decision(decision_id)`                                                                                              | Fetch a single recorded decision (`DecisionLogResult`). Reads `/v1/decisions/{decision_id}`.                                               |
| `record_outcome(decision_id, *, actual_outcome, outcome_notes=None)`                                                     | Attach the realized outcome to a decision (`DecisionLogResult`). Posts to `/v1/decisions/{decision_id}/outcome`.                           |
| `execute_decision(decision_id, *, webhook_url, timeout_seconds=10.0, force=False, override_safety=False, metadata=None)` | Execute a recorded decision via a webhook and return a receipt (`ExecutionReceiptResult`). Posts to `/v1/decisions/{decision_id}/execute`. |
| `delete_decision(decision_id)`                                                                                           | Delete a recorded decision. Sends `DELETE /v1/decisions/{decision_id}`.                                                                    |

## Example: log a decision and record its outcome

```python
import os
from decision_engine import AlgentaClient

client = AlgentaClient(api_key=os.environ["ALGENTA_API_KEY"])

# Record a decision.
logged = client.log_decision(
    {
        "chosen_action": "Scale checkout service",
        "expected_value": 42000,
        "context": "Checkout p95 latency at 820ms",
    }
)

# Later, attach what actually happened.
updated = client.record_outcome(
    logged.id,
    actual_outcome=39500,
    outcome_notes="Latency improved; revenue slightly below forecast.",
)

# Review decisions that already have an outcome.
history = client.list_decisions(with_outcome_only=True, limit=20)
for decision in history.decisions:
    print(decision.id, decision.chosen_action)
```

## Example: forecast product metrics

```python
import os
from decision_engine import AlgentaClient

client = AlgentaClient(api_key=os.environ["ALGENTA_API_KEY"])

forecast = client.product_forecast(
    {
        "product_id": "sku-1042",
        "metric": "units_sold",
        "horizon": 6,
    }
)
for period in forecast.periods:
    print(period.period, period.forecast)
```

## Related pages

{% content-ref url="/pages/tGlnNUppZSD65MAWJvD0" %}
[Log decisions & record outcomes](/guides/decision-memory.md)
{% endcontent-ref %}

{% content-ref url="/pages/ktXIojcv61EsP0IhlJTb" %}
[Decision memory](/concepts/decision-memory.md)
{% endcontent-ref %}

{% content-ref url="/pages/l0mqGrhl5ic9OfaGy52Q" %}
[Simulations & queries](/sdks/python/simulations-and-queries.md)
{% endcontent-ref %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.algenta.ai/sdks/python/decisions-and-products.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
