Skip to content

6.3 Assistants and configuration ​

This chapter reorganizes the upstream notebook and Python implementation into a web lesson. The teaching notes were prepared for this site with a matching Chinese edition.

Source notebook · Python implementation and configuration

Version and environment

Code follows the upstream snapshot dated 2025-10-12, not a compatibility promise for current SDKs. Original code cells appear below in notebook order, including Jupyter magic such as %pip / %%capture; execute them separately in a notebook. Configure credentials locally, never in a web page or Git. This site renders lessons; the paid model calls and Docker exercises have not been executed here.

One graph, different configurations ​

An assistant binds configuration to a graph so you can experiment without copying graph code. configuration.py exposes user_id, todo_category and task_maistro_role. Assistants here are LangGraph server resources, not a reference to another vendor’s Assistants API.

Separate personal and work tasks ​

Create personal and work assistants with distinct todo_category and role instructions. The graph reads these configurable fields in its nodes. Store namespaces use the category as well as user identity, allowing separate lists for one user. A client-supplied user_id is not authentication.

Manage assistant versions ​

The notebook searches assistants, updates the personal assistant configuration to create a new version, and creates a work assistant. It also creates a spare assistant solely to demonstrate deletion. Replace example IDs with IDs returned by your server.

Original code cells ​

Comments and identifiers remain as supplied upstream. Cells share variables from earlier cells; saved outputs and historical screenshots are not results from this website.

Cell 1 ​

python
%%capture --no-stderr
%pip install -U langgraph_sdk

Cell 2 ​

python
from langgraph_sdk import get_client
url_for_cli_deployment = "http://localhost:8123"
client = get_client(url=url_for_cli_deployment)

Cell 3 ​

python
personal_assistant = await client.assistants.create(
    # "task_maistro" is the name of a graph we deployed
    "task_maistro",
    config={"configurable": {"todo_category": "personal"}}
)
print(personal_assistant)

Cell 4 ​

python
task_maistro_role = """You are a friendly and organized personal task assistant. Your main focus is helping users stay on top of their personal tasks and commitments. Specifically:

- Help track and organize personal tasks
- When providing a 'todo summary':
  1. List all current tasks grouped by deadline (overdue, today, this week, future)
  2. Highlight any tasks missing deadlines and gently encourage adding them
  3. Note any tasks that seem important but lack time estimates
- Proactively ask for deadlines when new tasks are added without them
- Maintain a supportive tone while helping the user stay accountable
- Help prioritize tasks based on deadlines and importance

Your communication style should be encouraging and helpful, never judgmental.

When tasks are missing deadlines, respond with something like "I notice [task] doesn't have a deadline yet. Would you like to add one to help us track it better?"""

configurations = {"todo_category": "personal",
                  "user_id": "lance",
                  "task_maistro_role": task_maistro_role}

personal_assistant = await client.assistants.update(
    personal_assistant["assistant_id"],
    config={"configurable": configurations}
)
print(personal_assistant)

Cell 5 ​

python
task_maistro_role = """You are a focused and efficient work task assistant.

Your main focus is helping users manage their work commitments with realistic timeframes.

Specifically:

- Help track and organize work tasks
- When providing a 'todo summary':
  1. List all current tasks grouped by deadline (overdue, today, this week, future)
  2. Highlight any tasks missing deadlines and gently encourage adding them
  3. Note any tasks that seem important but lack time estimates
- When discussing new tasks, suggest that the user provide realistic time-frames based on task type:
  • Developer Relations features: typically 1 day
  • Course lesson reviews/feedback: typically 2 days
  • Documentation sprints: typically 3 days
- Help prioritize tasks based on deadlines and team dependencies
- Maintain a professional tone while helping the user stay accountable

Your communication style should be supportive but practical.

When tasks are missing deadlines, respond with something like "I notice [task] doesn't have a deadline yet. Based on similar tasks, this might take [suggested timeframe]. Would you like to set a deadline with this in mind?"""

configurations = {"todo_category": "work",
                  "user_id": "lance",
                  "task_maistro_role": task_maistro_role}

work_assistant = await client.assistants.create(
    # "task_maistro" is the name of a graph we deployed
    "task_maistro",
    config={"configurable": configurations}
)
print(work_assistant)

Cell 6 ​

python
assistants = await client.assistants.search()
for assistant in assistants:
    print({
        'assistant_id': assistant['assistant_id'],
        'version': assistant['version'],
        'config': assistant['config']
    })

Cell 7 ​

python
# create a temporary assitant
temp_assistant = await client.assistants.create(
    "task_maistro",
    config={"configurable": configurations}
)

assistants = await client.assistants.search()
for assistant in assistants:
    print(f"before delete: {{'assistant_id': {assistant['assistant_id']}}}")

# delete our temporary assistant
await client.assistants.delete(assistants[-1]["assistant_id"])
print()

assistants = await client.assistants.search()
for assistant in assistants:
    print(f"after delete: {{'assistant_id': {assistant['assistant_id']} }}")

Cell 8 ​

python
work_assistant_id = assistants[0]['assistant_id']
personal_assistant_id = assistants[1]['assistant_id']

Cell 9 ​

python
from langchain_core.messages import HumanMessage
from langchain_core.messages import convert_to_messages

user_input = "Create or update few ToDos: 1) Re-film Module 6, lesson 5 by end of day today. 2) Update audioUX by next Monday."
thread = await client.threads.create()
async for chunk in client.runs.stream(thread["thread_id"],
                                      work_assistant_id,
                                      input={"messages": [HumanMessage(content=user_input)]},
                                      stream_mode="values"):

    if chunk.event == 'values':
        state = chunk.data
        convert_to_messages(state["messages"])[-1].pretty_print()

Cell 10 ​

python
user_input = "Create another ToDo: Finalize set of report generation tutorials."
thread = await client.threads.create()
async for chunk in client.runs.stream(thread["thread_id"],
                                      work_assistant_id,
                                      input={"messages": [HumanMessage(content=user_input)]},
                                      stream_mode="values"):

    if chunk.event == 'values':
        state = chunk.data
        convert_to_messages(state["messages"])[-1].pretty_print()

Cell 11 ​

python
user_input = "OK, for this task let's get it done by next Tuesday."
async for chunk in client.runs.stream(thread["thread_id"],
                                      work_assistant_id,
                                      input={"messages": [HumanMessage(content=user_input)]},
                                      stream_mode="values"):

    if chunk.event == 'values':
        state = chunk.data
        convert_to_messages(state["messages"])[-1].pretty_print()

Cell 12 ​

python
user_input = "Create ToDos: 1) Check on swim lessons for the baby this weekend. 2) For winter travel, check AmEx points."
thread = await client.threads.create()
async for chunk in client.runs.stream(thread["thread_id"],
                                      personal_assistant_id,
                                      input={"messages": [HumanMessage(content=user_input)]},
                                      stream_mode="values"):

    if chunk.event == 'values':
        state = chunk.data
        convert_to_messages(state["messages"])[-1].pretty_print()

Cell 13 ​

python
user_input = "Give me a todo summary."
thread = await client.threads.create()
async for chunk in client.runs.stream(thread["thread_id"],
                                      personal_assistant_id,
                                      input={"messages": [HumanMessage(content=user_input)]},
                                      stream_mode="values"):

    if chunk.event == 'values':
        state = chunk.data
        convert_to_messages(state["messages"])[-1].pretty_print()

Practice and checks ​

Add one task through each assistant, then query each category. Verify that changing role instructions affects task creation while the lists remain separate. Delete only the spare test assistant.

For the full original narrative, saved outputs and diagrams, consult the notebook.

English translation of community learning materials. MIT licensed.