# Pure Python

```
def word_count(text: str) -> int:
    """Count the number of words in a text.

    Args:
        text: Input text.

    Returns:
        The word count.
    """
    return len(text.split())
```

| Operation | Implementation |
| --- | --- |
| Fixed algorithm, data conversion, counting, file reading and writing, math | Ordinary Python helper or Agent method; no `llm()`, no `runtime` parameter, a standard Google-style docstring |
| Natural-language generation, classification, reasoning | Explicit `agent()` or `self(...)` request |

## In the session DAG

```
from openprogram import Agent

class TextAgent(Agent):
    def word_count(self, text: str) -> int:
        """Count words."""
        return len(text.split())
```

| Function | Recording |
| --- | --- |
| Agent method that starts an execution | Recorded; needs no model request or tool registration |
| Helper nested in that execution, or in a managed Program source | Runs in the active call scope; no node of its own |
| Arbitrary host function | Not captured |

Being deterministic does not decide recording. Set `tool=True` only when the model should be able to call it.
