Part 1

How my website chat became an agent

Why my portfolio has a chat, what the first version could do, and how it grew into an agent with tools, project cards and a direct path to a conversation.

Phillipp Bertram9 min read
  • AI agents
  • Architecture
The website chat answering a question about AI agents, with the linked Pricewerk project card below the answer.
Contents5 sections

Visitors to this site usually come with questions. What do you offer? How much experience do you have with AI agents? When could you start? The answers are all on the page, spread across services, projects and the FAQ. A chat can answer the question that was asked, without anyone piecing it together.

That was one reason. The other was simpler: I wanted to try it. A chat makes the site more interactive than a page you scroll through, and building one meant learning new technology hands-on instead of reading about it. Where better to do that than on my own website, my own playground?

Trying it out was easy. Answering well took longer. A tester once asked the chat whether I had experience with home automation. The chat answered that it had no information about that. I had worked on JUNG HOME, a smart home app, and my own chat didn't know. Everything it knew came from a prompt I had typed by hand, and that prompt had a gap exactly where the question landed.

Today the chat is an agent that builds its knowledge from this site's content, shows project cards and can take an inquiry. This series looks inside it. Part 1 tells why it exists, where it started and how it grew.

The map below shows the four stages side by side, from the model and what the chat knew to how I protected the routes and checked quality. Pick a stage to see what changed; new parts are marked in copper.

How the chat grew

A labelled first person, extra knowledge and blog articles, checked by 71 eval cases.

Model
  • gpt-5.2
Runtime
  • OpenAI Agents SDK
  • AI SDK UI stream
Knowledge
  • Website content
  • Extra agent knowledge
  • Blog articles
Answers
  • Text
  • Project cards
  • Project brief
Conversation
  • Browser session
Next step
  • Booking link
  • Inquiry by mail
Protection
  • Origin check
  • BotID
  • Rate limits
Quality
  • Airtable log
  • Answer feedback
  • 71 eval cases
Voice
  • First person, labelled

Why a chat at all

Trying things out is a good reason to start. To keep something running for almost two years, I need more. These are the reasons it stays:

  • It answers from what I have published. When an answer mentions a project, the project card comes with it, so claim and evidence sit next to each other.
  • It shows instead of claiming. Writing "I build AI features into products" is easy. Letting visitors try one, on real content and with real limits, says more.
  • It is still my playground, now with real stakes. I try agent patterns and SDKs here before I recommend them. The site has everything a client project has, only smaller: costs, misuse, wrong answers and people who ask things nobody planned for.
  • It shortens the way to a conversation. Whoever has described a project in the chat shouldn't have to start again in an email. The chat turns the key points into an inquiry.

Where it started

The first version went live on 6 February 2025. It was a separate /chat page built on an open source chat template and the Vercel AI SDK. Each message triggered one streamText call to gpt-4o with a prompt I had written by hand. The answer streamed back, and both sides of the conversation were logged to Airtable. This is the heart of that first route, shortened:

route.ts, February 2025
ts
// gpt-4o       - $2.50 / 1M input tokens
// gpt-4o-mini  - $0.150 / 1M input tokens
const MODEL_NAME = 'gpt-4o';
const model = openai(MODEL_NAME);

export async function POST(req: Request) {
  const result = streamText({
    model,
    system: SYSTEM_PROMPT,
    temperature: 0.7,
    messages,
    async onFinish(event) {
      await storeChatMessageInAirTable({
        chatId: id,
        message: { role: 'assistant', content: event.text },
      });
    },
  });

  return result.toDataStreamResponse();
}

The price list above the model name says a lot about that version: it was an experiment I watched closely, not a product I had planned.

The welcome text was honest: "I'm an AI assistant trained to help you learn more about Phillipp." Five days later, the prompt learned my booking link, a few nerdy jokes and to answer "42" when someone asks about the meaning of life. That rule is still there, and it has its own test now.

The same update repeated one rule in capital letters: answer in the language of the question. It had been in the prompt from the start, and English questions still sometimes got German answers. Shouting didn't settle it. Testers found more: the home automation gap, and an off-topic reply saying the chat could only answer questions about me or itself, which sounded more like a bouncer than a host.

Looking back, I would write a small set of test questions on day one. The home automation gap would have shown up in an afternoon instead of in a tester's message. My wish list was short: keep the conversation, send a summary to the visitor and me, and make booking a call easy.

How it grew

  1. Feb 2025

    The first chat version went live, and the wish list was written.

    14 monthsA wish list is patient.

  2. Jan 2026

    I rebuilt the site. The chat came along, and that was all.

  3. Apr 2026

    From a call to an agent

    I replaced the direct calls with the OpenAI Agents SDK and moved to gpt-5.2. There was no grand plan behind it. The chat already ran on OpenAI models, I wanted to try the SDK, and this chat is where I try things first. It also kept a door open: an adapter in its extensions package runs the same agent with models from other providers, so a later switch wouldn't mean adopting a new agent framework first. For half a year it was an agent with nothing to do; the tools only arrived in October.

    The change that mattered more is less visible: the prompt is no longer written by hand but built from the same content as the website. A correction on the site corrects the chat, and a project in my portfolio can't be missing from the prompt. That closed the kind of gap the home automation question had found.

    One source, two places
    lib/content.tsprojects, CV, services+ JUNG HOME
    Website+ JUNG HOMEwhat visitors read
    Agent prompt+ JUNG HOMEwhat the agent knows
    A project I add to the site is in the agent's prompt with the next deploy.

    The goal changed too: help visitors judge whether I fit their project.

  4. Oct 2026

    Old debts, paid

    This was the big rebuild. showProjects puts project cards below an answer, updateProjectBrief notes down what a visitor says about their project, and the chat learned to draft an inquiry and then to send it, because a mailto: draft often got lost on phones. The browser keeps the conversation now, so it doesn't matter which server instance answers. And I wrote the first 25 evals: fixed test questions with checks for the answers, the ones I should have written on day one.

    On the way, three things from February 2025 finally got done. The rate limit stopped being a TODO and arrived together with Vercel's bot detection, the reply language is decided in code instead of in capital letters, and about 4,500 lines of unused template code are gone:

    Old debts
    Rate limit// TODO: rate limitFeb 2025await guardChatRequest(​req, 'chat')Oct 2026 · 632 days later
    Reply languageANTWORTE IN DER SPRACHE, IN DER DIE FRAGE GESTELLT WORDEN IST.Feb 2025resolveReplyLanguage(​visitorTexts)Oct 2026 · in code
    Template~4,500 lines of chat template nobody usedOct 2026 · deleted
  5. Nov 2026

    From assistant to agent

    For a few weeks the chat spoke about me in the third person, as my AI assistant. That was correct, and it read like a press release about myself. Now it answers in the first person again.

    Then I stopped guessing how much context the agent needs and measured it: three ways of giving it, 71 eval cases each. The leanest cut the input tokens in half and then declared experience I do have as undocumented. I chose the middle one:

    Context for the agent
    Old promptthe rules before November17,57768/71
    Compactchosenshorter rules, all facts12,21670/71
    Leanoverview, facts on demand8,40266/71
    Average input tokens per answer and passed cases. gpt-5.2, one run on 12 November 2026.

    About 30 % fewer input tokens than the old prompt, 70 of 71 cases passed, and the one failure was an answer ten words over the limit.

Where it stands now

Today the browser keeps the chat in session storage and sends the last 12 messages with each question. On the server, a route checks the origin, bot protection and rate limits, then starts one agent run. The agent itself is small. Shortened, it looks like this:

chat-agent.ts
ts
export function createChatAgent(
  variant: ChatContextVariant = DEFAULT_CHAT_CONTEXT_VARIANT,
  options: ChatAgentOptions = {},
) {
  return new Agent({
    name: 'PhillippBertram',
    instructions: getChatAgentInstructions(variant, options),
    model: CHAT_MODEL_NAME,
    tools: [
      variant === 'baseline' ? showProjectsTool : createShowProjectsTool(true),
      updateProjectBriefTool,
      // …
    ],
    modelSettings: {
      maxTokens: CHAT_MAX_OUTPUT_TOKENS,
      retry: { maxRetries: 3, policy: retryTransientErrors },
      // Brief and project cards in one step; otherwise the model often drops the cards.
      parallelToolCalls: true,
      // …
    },
  });
}

instructions is the prompt: the agent's rules, the facts from my website and a file of extra knowledge that isn't on the site, such as which client projects belong to which employer. variant picks one of three ways to assemble that context. The baseline in the code is the old setup, kept so the evals can still compare against it. How I chose between them is in the November stage above.

Why it is still the Agents SDK. The chat still runs on OpenAI models, so the main reason from April still holds. Not every part of the SDK earned its place, though. I used its sessions in April and dropped them in October, when the conversation moved into the browser. What stayed does real work:

  • The loop. showProjects and updateProjectBrief are plain functions with a zod schema. The SDK calls them when the model asks for them and sends the results back, in parallel when the model wants both.
  • Traces. Every run shows up in OpenAI's trace view, grouped as "Website Chat · Production", "Preview", "Local" and "Eval". For a strange answer I can see what the model got, which tools it called and how long each step took.
  • One agent for the chat and the evals. The eval runner builds the agent with the same createChatAgent, so the 71 cases test the code that answers visitors.
  • The interface stayed. createAiSdkUiMessageStream turns the agent's events into the AI SDK's UI stream, and React renders text, steps and cards as they arrive.

And the door from April is still open: if I want a model from another provider one day, the adapter is where I'd start, not a new framework.

Airtable keeps a log of the messages; inquiries are logged without names or email addresses.

Some limits are deliberate. The agent has no memory beyond the current conversation. It answers from published facts and says when something isn't documented. And it doesn't design architectures or estimate projects; those questions belong in a real conversation with me.

In short

  • A chat on a portfolio site earns its place when it answers from published facts and shows the evidence next to the answer.
  • A prompt written by hand has gaps you only find when someone asks. Building it from the site's content closes them.
  • The step from one model call to an agent came with tools: project cards, a brief and an inquiry are things the chat does, not only says.
  • Evals turned "it feels better" into numbers, and those numbers decided how much context the agent gets.

Next in the series

Part 2 follows one project link from the streamed answer to the React card, and tells why the cards used to go missing.

If you'd rather see the result than read about it, ask the agent below. This article goes along as context.

Series

2 parts published

Building my website agent

  1. 01How my website chat became an agentYou are here
  2. 02How my chat turns links into project cards

Written by

Phillipp Bertram

Software development and AI from Osnabrück

Ask my agent about this article

The article goes along as context. The answer opens in the chat.