> For the complete documentation index, see [llms.txt](https://whitepaper.aitech.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://whitepaper.aitech.io/agentforge/execution-engine/advanced.md).

# advanced

Agent Forge provides comprehensive logging for workflow executions and automatic cost calculation for AI model usage.

## Logging System

Agent Forge offers two complementary logging interfaces:

### Real-Time Console (Manual Executions)

During manual workflow execution, logs appear in real-time in the Console panel on the right side of the workflow editor.

The console shows:

* Block execution progress with active block highlighting
* Real-time outputs as blocks complete
* Execution timing for each block
* Success/error status indicators

### Logs Page (All Executions)

All workflow executions—whether triggered manually, via API, Chat, Schedule, or Webhook—are logged to the dedicated Logs page.

The Logs page provides:

* Comprehensive filtering by time range, status, trigger type, folder, and workflow
* Search functionality across all logs
* Live mode for real-time updates
* 7-day log retention (upgradeable for longer retention)

## Log Details Sidebar

Clicking on any log entry opens a detailed sidebar view.

### Block Input/Output

View the complete data flow for each block with tabs to switch between:

{% tabs %}
{% tab title="Output" %}
**Output Tab** shows the block's execution result:

* Structured data with JSON formatting
* Markdown rendering for AI-generated content
* Copy button for easy data extraction
  {% endtab %}

{% tab title="Input" %}
**Input Tab** displays what was passed to the block:

* Resolved variable values
* Referenced outputs from other blocks
* Environment variables used
* API keys are automatically redacted for security
  {% endtab %}
  {% endtabs %}

### Execution Timeline

For workflow-level logs, view detailed execution metrics:

* Start and end timestamps
* Total workflow duration
* Individual block execution times
* Performance bottleneck identification

### Model Breakdown

For workflows using AI blocks, expand the Model Breakdown section to see:

* **Token Usage**: Input and output token counts for each model
* **Cost Breakdown**: Individual costs per model and operation
* **Model Distribution**: Which models were used and how many times
* **Total Cost**: Aggregate cost for the entire workflow execution

### Workflow Snapshot

For any logged execution, click "View Snapshot" to see the exact workflow state at execution time.

The snapshot provides:

* Frozen canvas showing the workflow structure
* Block states and connections as they were during execution
* Click any block to see its inputs and outputs
* Useful for debugging workflows that have since been modified

{% hint style="info" %}
Workflow snapshots are only available for executions after the enhanced logging system was introduced. Older migrated logs show a "Logged State Not Found" message.
{% endhint %}

## Cost Calculation

Agent Forge automatically calculates costs for all AI model usage:

### How Costs Are Calculated

Every workflow execution includes two cost components:

**Base Execution Charge**: $0.001 per execution

**AI Model Usage**: Variable cost based on token consumption

```javascript
modelCost = (inputTokens × inputPrice + outputTokens × outputPrice) / 1,000,000
totalCost = baseExecutionCharge + modelCost
```

{% hint style="info" %}
AI model prices are per million tokens. The calculation divides by 1,000,000 to get the actual cost. Workflows without AI blocks only incur the base execution charge.
{% endhint %}

### Pricing Options

{% hint style="warning" %}
Pricing shown reflects rates as of July 14, 2025. Check provider documentation for current pricing.
{% endhint %}

### Cost Optimization

<details>

<summary>Model Selection</summary>

Choose models based on task complexity. Simple tasks can use GPT-4.1-nano ($0.10/$0.40) while complex reasoning might need o1 or Claude Opus.

</details>

<details>

<summary>Prompt Engineering</summary>

Well-structured, concise prompts reduce token usage without sacrificing quality.

</details>

## Usage Monitoring

Monitor your usage and billing in Settings → Subscription:

* **Current Usage**: Real-time usage and costs for the current period
* **Usage Limits**: Plan limits with visual progress indicators
* **Billing Details**: Projected charges and minimum commitments
* **Plan Management**: Upgrade options and billing history
