LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • LangGraph Checkpoint
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    LangGraph Checkpoint
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    Language
    Theme
    Pythonlanggraph-sdk_synccronSyncCronClientcreate_for_thread
    Method●Since v0.3

    create_for_thread

    Copy
    create_for_thread(
      self,
      thread_id: str,
      assistant_id: str,
      *,
      
    View source on GitHub
    schedule
    :
    str
    ,
    input
    :
    Input
    |
    None
    =
    None
    ,
    metadata
    :
    Mapping
    [
    str
    ,
    Any
    ]
    |
    None
    =
    None
    ,
    config
    :
    Config
    |
    None
    =
    None
    ,
    context
    :
    Context
    |
    None
    =
    None
    ,
    checkpoint_during
    :
    bool
    |
    None
    =
    None
    ,
    interrupt_before
    :
    All
    |
    list
    [
    str
    ]
    |
    None
    =
    None
    ,
    interrupt_after
    :
    All
    |
    list
    [
    str
    ]
    |
    None
    =
    None
    ,
    webhook
    :
    str
    |
    None
    =
    None
    ,
    multitask_strategy
    :
    str
    |
    None
    =
    None
    ,
    end_time
    :
    datetime
    |
    None
    =
    None
    ,
    enabled
    :
    bool
    |
    None
    =
    None
    ,
    timezone
    :
    str
    |
    tzinfo
    |
    None
    =
    None
    ,
    stream_mode
    :
    StreamMode
    |
    Sequence
    [
    StreamMode
    ]
    |
    None
    =
    None
    ,
    stream_subgraphs
    :
    bool
    |
    None
    =
    None
    ,
    stream_resumable
    :
    bool
    |
    None
    =
    None
    ,
    durability
    :
    Durability
    |
    None
    =
    None
    ,
    headers
    :
    Mapping
    [
    str
    ,
    str
    ]
    |
    None
    =
    None
    ,
    params
    :
    QueryParamTypes
    |
    None
    =
    None
    )
    ->
    Run

    Parameters

    NameTypeDescription
    thread_id*str

    the thread ID to run the cron job on.

    assistant_id*str

    The assistant ID or graph name to use for the cron job. If using graph name, will default to first assistant created from that graph.

    schedule*str

    The cron schedule to execute this job on. Schedules are interpreted in UTC unless a timezone is specified.

    inputInput | None
    Default:None
    metadataMapping[str, Any] | None
    Default:None
    configConfig | None
    Default:None
    contextContext | None
    Default:None
    checkpoint_duringbool | None
    Default:None
    interrupt_beforeAll | list[str] | None
    Default:None
    interrupt_afterAll | list[str] | None
    Default:None
    webhookstr | None
    Default:None
    multitask_strategystr | None
    Default:None
    end_timedatetime | None
    Default:None
    enabledbool | None
    Default:None
    timezonestr | tzinfo | None
    Default:None
    stream_modeStreamMode | Sequence[StreamMode] | None
    Default:None
    stream_subgraphsbool | None
    Default:None
    stream_resumablebool | None
    Default:None
    durabilityDurability | None
    Default:None
    headersMapping[str, str] | None
    Default:None

    Create a cron job for a thread.

    client = get_sync_client(url="http://localhost:8123")
    cron_run = client.crons.create_for_thread(
        thread_id="my-thread-id",
        assistant_id="agent",
        schedule="27 15 * * *",
        input={"messages": [{"role": "user", "content": "hello!"}]},
        metadata={"name":"my_run"},
        context={"model_name": "openai"},
        interrupt_before=["node_to_stop_before_1","node_to_stop_before_2"],
        interrupt_after=["node_to_stop_after_1","node_to_stop_after_2"],
        webhook="https://my.fake.webhook.com",
        multitask_strategy="interrupt",
        enabled=True
    )

    The input to the graph.

    Metadata to assign to the cron job runs.

    The configuration for the assistant.

    Static context to add to the assistant.

    (deprecated) Whether to checkpoint during the run (or only at the end/interruption).

    Nodes to interrupt immediately before they get executed.

    Nodes to Nodes to interrupt immediately after they get executed.

    Webhook to call after LangGraph API call is done.

    Multitask strategy to use. Must be one of 'reject', 'interrupt', 'rollback', or 'enqueue'.

    The time to stop running the cron job. If not provided, the cron job will run indefinitely.

    Whether the cron job is enabled. By default, it is considered enabled.

    IANA timezone for the cron schedule. Accepts a string (e.g. 'America/New_York') or a datetime.tzinfo instance (e.g. ZoneInfo("America/New_York")).

    The stream mode(s) to use.

    Whether to stream output from subgraphs.

    Whether to persist the stream chunks in order to resume the stream later.

    Durability level for the run. Must be one of 'sync', 'async', or 'exit'. "async" means checkpoints are persisted async while next graph step executes, replaces checkpoint_during=True "sync" means checkpoints are persisted sync after graph step executes, replaces checkpoint_during=False "exit" means checkpoints are only persisted when the run exits, does not save intermediate steps

    Optional custom headers to include with the request.