> ## Documentation Index
> Fetch the complete documentation index at: https://docs.onecortex.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Entrypoints: how your agent is found

> Point agent.yml at your agent object, and learn how Onecortex recognises it for each framework, or serves it as a plain function.

`entrypoint` in `agent.yml` names the one object in your code that is the agent. Onecortex imports it once, when your agent starts, recognises what it is, and calls it on every request. You do not write a server: no FastAPI, no Express, no port, no Dockerfile.

## The format

<Tabs>
  <Tab title="Python">
    A file and a name at its top level, separated by a colon:

    ```yaml agent.yml theme={null}
    entrypoint: agent.py:agent
    ```

    A file in a subfolder is `src/agent.py:graph`. The path is relative to the agent folder.
  </Tab>

  <Tab title="TypeScript">
    A file and a named export, separated by `#`:

    ```yaml agent.yml theme={null}
    entrypoint: agent.ts#agent
    ```

    `.ts`, `.mts`, `.cts`, `.js`, `.mjs` and `.cjs` files work. TypeScript runs directly: there is no build step to set up.
  </Tab>
</Tabs>

## How the object is recognised

Onecortex looks at the object itself, in this order, and uses the first match. It never reads the `framework` field in `agent.yml` to decide.

<Tabs>
  <Tab title="Python">
    | Order | Object | Framework page |
    | - | - | - |
    | 1 | A compiled LangGraph graph (`StateGraph(...).compile()`) | [LangGraph](/frameworks/langgraph) |
    | 2 | A Strands `Agent` | [Strands Agents](/frameworks/strands) |
    | 3 | A CrewAI `Crew` | [CrewAI](/frameworks/crewai) |
    | 4 | A LangChain chain or `AgentExecutor`: anything with `invoke` and `input_keys` | [LangChain](/frameworks/langchain) |
    | 5 | A LlamaIndex `AgentWorkflow` or `FunctionAgent` | [LlamaIndex](/frameworks/llamaindex) |
    | 6 | An OpenAI Agents SDK `Agent` | [OpenAI Agents SDK](/frameworks/openai-agents) |
    | 7 | Anything else: a function, a class instance you can call, or an object with `invoke` | [A Python function](/frameworks/python-function) |
  </Tab>

  <Tab title="TypeScript">
    | Order | Object | Framework page |
    | - | - | - |
    | 1 | A Mastra `Agent` | [Mastra](/frameworks/mastra) |
    | 2 | A Vercel AI SDK agent, such as `ToolLoopAgent` | [Vercel AI SDK](/frameworks/vercel-ai) |
    | 3 | A LangChain.js runnable | [LangChain.js](/frameworks/langchain-js) |
    | 4 | Anything else: a function, or an object with `invoke` | [A TypeScript function](/frameworks/typescript-function) |
  </Tab>
</Tabs>

An uncompiled LangGraph `StateGraph` is not a graph you can run, so it is not recognised: export the result of `.compile()`.

## A plain function always works

If your agent is on a framework not listed, or on none, point the entrypoint at a function. It takes the prompt, and returns the reply or yields it in pieces:

<Tabs>
  <Tab title="Python">
    ```python agent.py theme={null}
    def agent(prompt: str) -> str:
        return f"You said: {prompt}"
    ```

    Sync and async functions, generators and async generators all work. Declare a second parameter to receive the session ID, or a parameter named `request` for the whole request, `params` included. See [A Python function](/frameworks/python-function).
  </Tab>

  <Tab title="TypeScript">
    ```ts agent.ts theme={null}
    export async function agent(prompt: string): Promise<string> {
      return `You said: ${prompt}`
    }
    ```

    Async functions and async generators work. The second argument is `{ sessionId, request }`, with `params` in `request`. See [A TypeScript function](/frameworks/typescript-function).
  </Tab>
</Tabs>

A function is also how you serve an agent from a framework Onecortex does not recognise, such as AutoGen or Pydantic AI: wrap its run call in a function and point the entrypoint at the function.

## Your code runs once at start

Onecortex imports your entrypoint's file when the agent's container starts, before any request. Anything at the top level of the file runs then. That is the right place to build your graph, load a model client or read a data file, and it is why an agent that starts slowly or not at all fails the build's [smoke test](/deploy/builds) rather than a customer's first call.

It is also the most common failure for a repository that used to run as a script. A file that starts a server, loops on `input()`, or calls a model at the top level hangs or crashes on import. Guard that code:

```python agent.py theme={null}
agent = build_agent()

if __name__ == "__main__":
    # Runs with `python agent.py`, never when Onecortex imports the file.
    while True:
        print(agent.invoke(input("> ")))
```

The working directory is your agent folder, so a relative path like `open("data.json")` reads a file from it.

## When the object is not found

| Message | What to do |
| - | - |
| ``agent.yml line <n>: `entrypoint` refers to `<file>`, which does not exist in the build context.`` | The file path is wrong. The message lists the files that are there. |
| ``agent.yml line <n>: `<name>` is not defined at module level in <file>.`` | The name is not at the top level of the file. The message lists the names that are. |
| `'<file>' has no attribute '<name>'. Found: <names>` | The same, found when the agent started. TypeScript says `has no export`. |
| `Failed to import '<file>'.` | Importing the file raised. The traceback under it says why. |
| `Onecortex could not determine how to invoke the object at your entrypoint (type: <type>).` | The object is not recognised and cannot be called. Point the entrypoint at a function. |

Every message is on [Errors](/production/errors).
