[GH-ISSUE #8611] /clear not actually clearing #5571

Closed
opened 2026-04-12 16:50:09 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @iplayfast on GitHub (Jan 27, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/8611

What is the issue?

Steps that I've done, which shows the bug. There might be a simpler sequence but this is mine.

  1. ollama run hf.co/mradermacher/DS-R1-Distill-Q2.5-7B-RP-GGUF:latest
  2. /set parameter num_ctx 16384
  3. save chrisdeepseek
  4. /bye
  5. ollama run chrisdeepseek
  6. create flappybird.py code.
  7. (do some testing extra)
  8. /bye
  9. ollama run chrisdeepseek
  10. flappy bird code comes back!
  11. /clear
  12. /bye
  13. ollama run chrisdeepseek
  14. flaapy bird code comes back!
    Seems like the larger context doesn't actually get cleared.

OS

Linux

GPU

Nvidia

CPU

Intel

Ollama version

0.5.7

Originally created by @iplayfast on GitHub (Jan 27, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/8611 ### What is the issue? Steps that I've done, which shows the bug. There might be a simpler sequence but this is mine. 1. ollama run hf.co/mradermacher/DS-R1-Distill-Q2.5-7B-RP-GGUF:latest 2. /set parameter num_ctx 16384 3. save chrisdeepseek 4. /bye 5. ollama run chrisdeepseek 6. create flappybird.py code. 7. (do some testing extra) 8. /bye 9. ollama run chrisdeepseek 10. flappy bird code comes back! 11. /clear 12. /bye 13. ollama run chrisdeepseek 14. flaapy bird code comes back! Seems like the larger context doesn't actually get cleared. ### OS Linux ### GPU Nvidia ### CPU Intel ### Ollama version 0.5.7
GiteaMirror added the bug label 2026-04-12 16:50:09 -05:00
Author
Owner

@rick-github commented on GitHub (Jan 27, 2025):

I assume by flaapy bird code comes back you mean it's in the console history when you press the up key. /clear just clears the context from the current session. If you want the contents of the session to not be saved, set OLLAMA_NOHISTORY=1 in the client environment.

<!-- gh-comment-id:2616593386 --> @rick-github commented on GitHub (Jan 27, 2025): I assume by `flaapy bird code comes back` you mean it's in the console history when you press the up key. `/clear` just clears the context from the current session. If you want the contents of the session to not be saved, set `OLLAMA_NOHISTORY=1` in the client environment.
Author
Owner

@iplayfast commented on GitHub (Jan 29, 2025):

You are assuming wrong. Here is a fresh start, after a few days and long after /clear was done. I did not type anything

more ~/bin/deepseek
#!/bin/bash
ollama run chrisdeepseek

deepseek 
>>> create python source code for flappy bird
<think>
Alright, I need to create Python code for Flappy Bird. Let me think about how to approach this.

First, I know that Flappy Bird is a simple game where a bird moves between pipes. The bird falls due to gravity and can jump when the player presses a key.

I'll start by setting up the basic structure. I'll need a display, so using the Pygame library makes sense. I'll initialize Pygame and set up the window dimensions.

Next, I'll define the bird's properties: position, velocity, acceleration due to gravity, and its color. The pipes will be stored in a list, each with an x-position, top height, bottom Y-coordinate, and whether it's active.

I need functions to handle game physics. One for updating the bird's movement, including applying gravity and checking for collisions. Another function will generate new pipes at intervals and remove them when they go off-screen.

Drawing is crucial. I'll create a function to draw the bird as a circle using Pygame's drawing tools. The pipes can be represented by rectangles, with each pipe having a top and bottom part.

The main game loop will handle events, update the game state, and redraw everything. I'll check for collisions between the bird and both the pipes and the screen edges to end the game.

User input is handled via key presses. I'll make sure the bird jumps only when the spacebar or a down arrow is pressed, avoiding physics-based jumps unless the user intends it.

Finally, I'll set up the game clock for smooth rendering and handle quitting the game properly. Testing will be important to ensure all parts work together seamlessly.

I should also consider adding a score counter and displaying it on the screen, but maybe that's optional for now. Overall, the code needs to be clean and well-commented for clarity.
</think>

Here's a simple Python implementation of Flappy Bird using Pygame:

```python
import pygame
import math
import random
import time

# Initialize Pygame
pygame.init()

# Set up the display
WIDTH = 800
HEIGHT = 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Flappy Bird")

# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
BLUE = (0, 0, 255)

# Bird properties
bird_size = 40
bird_x = WIDTH // 4
bird_y = HEIGHT // 3
bird_velocity = 0
bird_gravity = 0.5
bird_jumped = False

# Pipe properties
pipe_width = 50
pipe_height = HEIGHT - 100
pipe_gap = 100

# Create pipes list
pipes = []

# Initialize clock
clock = pygame.time.Clock()

def draw_bird(x, y):
    # Draw bird as a circle
    pygame.draw.circle(screen, BLUE, (x, y), bird_size)

def create_pipe():
    # Create new pipe at random height
    top_height = random.randint(pipe_gap // 2 + 1, HEIGHT - pipe_height)
    bottom_height = top_height + pipe_height
    return {
        'x': WIDTH,
        'top_height': top_height,
        'bottom_height': bottom_height,
        'active': True
    }

def update_bird():
    global bird_x, bird_y, bird_jumped

    # Apply gravity
    if not bird_jumped:
        bird_velocity += bird_gravity
    else:
        bird_velocity = 0

    # Update bird position
    bird_y += bird_velocity

    # Check collision with pipes and screen
    for pipe in pipes:
        if (bird_x + bird_size > pipe['x'] - pipe['width'] and 
            bird_x < pipe['x'] + pipe_width):
            pygame.draw.rect(screen, BLACK, (bird_x, bird_y, bird_size*2, bird_size))
            return False

    # Check bottom collision
    if bird_y + bird_size > HEIGHT:
        return False

    # Jump when spacebar is pressed
    if pygame.key.get_pressed()[pygame.K_SPACE] and not bird_jumped:
        bird_jumped = True
        bird_velocity = -12

    return True

def update_pipes():
    global pipes

    # Remove off-screen pipes
    new_pipes = []
    for pipe in pipes:
        pipe['x'] -= 1
        if pipe['x'] < -pipe_width:
            pipes = new_pipes
            continue
        # Check collision with bird
        if (pipe['x'] + pipe_width > bird_x and 
            pipe['x'] < bird_x + bird_size):
            return False
        # Update top and bottom heights
        if pipe['top_height'] - 20 > HEIGHT:
            new_pipe = create_pipe()
            pipes.append(new_pipe)
            new_pipes.append(new_pipe)
        else:
            new_pipes.append(pipe)
    pipes = new_pipes
    return True

def draw_pipes():
    for pipe in pipes:
        # Top part of the pipe
        pygame.draw.rect(screen, RED, (pipe['x'], pipe['top_height'], pipe_width, pipe_gap))
        # Bottom part of the pipe
        pygame.draw.rect(screen, RED, (pipe['x'], pipe['bottom_height'], pipe_width, pipe_gap))

def game_loop():
    while True:
        clock.tick(60)

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                return

            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_SPACE and not bird_jumped:
                    bird_jumped = True
                    bird_velocity = -12

        # Update game state
        update_bird()
        if update_pipes():
            return False  # Game over!

        # Draw everything
        screen.fill(WHITE)
        draw_bird(bird_x, bird_y)
        draw_pipes()

        pygame.display.flip()

if __name__ == "__main__":
    running = True

    while running:
        clock.tick(60)

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                running = False
                break

        # Create initial pipes
        pipe_interval = 1500
        if len(pipes) < 3 and time.time() - last_pipe_time > pipe_interval:
            create_pipe()
            last_pipe_time = time.time()

    pygame.quit()

This implementation includes the following features:

  1. A simple bird character that can jump when the spacebar is pressed
  2. Pipes that move from right to left across the screen
  3. Collision detection with both pipes and the bottom of the screen
  4. Gravity simulation for the bird's fall
  5. Score system (not implemented in this code, but you can add it)
  6. Responsive controls

To play:

  1. Press spacebar when the bird is at the bottom to make it jump
  2. Avoid hitting the pipes and the bottom of the screen

The game runs until you either:

  • Die by colliding with a pipe or the bottom
  • Clear the level by reaching the end (though this implementation doesn't have levels yet)

You can customize various aspects like colors, dimensions, gravity, and pipe generation rates by modifying the constants at the top.

To run the game, save this code in a Python file (e.g., flappy_bird.py) and execute it with:

python flappy_bird.py

The bird will start at the bottom of the screen, and you can begin playing immediately.

<!-- gh-comment-id:2622783893 --> @iplayfast commented on GitHub (Jan 29, 2025): You are assuming wrong. Here is a fresh start, after a few days and long after /clear was done. I did not type anything more ~/bin/deepseek #!/bin/bash ollama run chrisdeepseek ``` deepseek >>> create python source code for flappy bird <think> Alright, I need to create Python code for Flappy Bird. Let me think about how to approach this. First, I know that Flappy Bird is a simple game where a bird moves between pipes. The bird falls due to gravity and can jump when the player presses a key. I'll start by setting up the basic structure. I'll need a display, so using the Pygame library makes sense. I'll initialize Pygame and set up the window dimensions. Next, I'll define the bird's properties: position, velocity, acceleration due to gravity, and its color. The pipes will be stored in a list, each with an x-position, top height, bottom Y-coordinate, and whether it's active. I need functions to handle game physics. One for updating the bird's movement, including applying gravity and checking for collisions. Another function will generate new pipes at intervals and remove them when they go off-screen. Drawing is crucial. I'll create a function to draw the bird as a circle using Pygame's drawing tools. The pipes can be represented by rectangles, with each pipe having a top and bottom part. The main game loop will handle events, update the game state, and redraw everything. I'll check for collisions between the bird and both the pipes and the screen edges to end the game. User input is handled via key presses. I'll make sure the bird jumps only when the spacebar or a down arrow is pressed, avoiding physics-based jumps unless the user intends it. Finally, I'll set up the game clock for smooth rendering and handle quitting the game properly. Testing will be important to ensure all parts work together seamlessly. I should also consider adding a score counter and displaying it on the screen, but maybe that's optional for now. Overall, the code needs to be clean and well-commented for clarity. </think> Here's a simple Python implementation of Flappy Bird using Pygame: ```python import pygame import math import random import time # Initialize Pygame pygame.init() # Set up the display WIDTH = 800 HEIGHT = 600 screen = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption("Flappy Bird") # Colors WHITE = (255, 255, 255) BLACK = (0, 0, 0) RED = (255, 0, 0) BLUE = (0, 0, 255) # Bird properties bird_size = 40 bird_x = WIDTH // 4 bird_y = HEIGHT // 3 bird_velocity = 0 bird_gravity = 0.5 bird_jumped = False # Pipe properties pipe_width = 50 pipe_height = HEIGHT - 100 pipe_gap = 100 # Create pipes list pipes = [] # Initialize clock clock = pygame.time.Clock() def draw_bird(x, y): # Draw bird as a circle pygame.draw.circle(screen, BLUE, (x, y), bird_size) def create_pipe(): # Create new pipe at random height top_height = random.randint(pipe_gap // 2 + 1, HEIGHT - pipe_height) bottom_height = top_height + pipe_height return { 'x': WIDTH, 'top_height': top_height, 'bottom_height': bottom_height, 'active': True } def update_bird(): global bird_x, bird_y, bird_jumped # Apply gravity if not bird_jumped: bird_velocity += bird_gravity else: bird_velocity = 0 # Update bird position bird_y += bird_velocity # Check collision with pipes and screen for pipe in pipes: if (bird_x + bird_size > pipe['x'] - pipe['width'] and bird_x < pipe['x'] + pipe_width): pygame.draw.rect(screen, BLACK, (bird_x, bird_y, bird_size*2, bird_size)) return False # Check bottom collision if bird_y + bird_size > HEIGHT: return False # Jump when spacebar is pressed if pygame.key.get_pressed()[pygame.K_SPACE] and not bird_jumped: bird_jumped = True bird_velocity = -12 return True def update_pipes(): global pipes # Remove off-screen pipes new_pipes = [] for pipe in pipes: pipe['x'] -= 1 if pipe['x'] < -pipe_width: pipes = new_pipes continue # Check collision with bird if (pipe['x'] + pipe_width > bird_x and pipe['x'] < bird_x + bird_size): return False # Update top and bottom heights if pipe['top_height'] - 20 > HEIGHT: new_pipe = create_pipe() pipes.append(new_pipe) new_pipes.append(new_pipe) else: new_pipes.append(pipe) pipes = new_pipes return True def draw_pipes(): for pipe in pipes: # Top part of the pipe pygame.draw.rect(screen, RED, (pipe['x'], pipe['top_height'], pipe_width, pipe_gap)) # Bottom part of the pipe pygame.draw.rect(screen, RED, (pipe['x'], pipe['bottom_height'], pipe_width, pipe_gap)) def game_loop(): while True: clock.tick(60) for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() return if event.type == pygame.KEYDOWN: if event.key == pygame.K_SPACE and not bird_jumped: bird_jumped = True bird_velocity = -12 # Update game state update_bird() if update_pipes(): return False # Game over! # Draw everything screen.fill(WHITE) draw_bird(bird_x, bird_y) draw_pipes() pygame.display.flip() if __name__ == "__main__": running = True while running: clock.tick(60) for event in pygame.event.get(): if event.type == pygame.QUIT: running = False break # Create initial pipes pipe_interval = 1500 if len(pipes) < 3 and time.time() - last_pipe_time > pipe_interval: create_pipe() last_pipe_time = time.time() pygame.quit() ``` This implementation includes the following features: 1. A simple bird character that can jump when the spacebar is pressed 2. Pipes that move from right to left across the screen 3. Collision detection with both pipes and the bottom of the screen 4. Gravity simulation for the bird's fall 5. Score system (not implemented in this code, but you can add it) 6. Responsive controls To play: 1. Press spacebar when the bird is at the bottom to make it jump 2. Avoid hitting the pipes and the bottom of the screen The game runs until you either: - Die by colliding with a pipe or the bottom - Clear the level by reaching the end (though this implementation doesn't have levels yet) You can customize various aspects like colors, dimensions, gravity, and pipe generation rates by modifying the constants at the top. To run the game, save this code in a Python file (e.g., `flappy_bird.py`) and execute it with: ```bash python flappy_bird.py ``` The bird will start at the bottom of the screen, and you can begin playing immediately. ```
Author
Owner

@rick-github commented on GitHub (Jan 29, 2025):

/save saves context which is replayed as user messages when the saved model is reloaded. To remove it from the model, clear and save.

Create a model with saved context:

$ ollama run test
>>> hello
Hello! How can I assist you today?

>>> /save test
Created new model 'test'
>>> /bye

Load a model with saved context. The previously entered "hello" prompt is replayed:

$ ollama run test
>>> hello
Hello! How can I assist you today?

>>> /bye

Load a model with saved context, clear it and save it:

$ ollama run test
>>> hello
Hello! How can I assist you today?

>>> /clear
Cleared session context
>>> /save test
Created new model 'test'
>>> /bye

Load a model that had saved context that was cleared:

$ ollama run test
>>> good morning
Good morning! How can I assist you today?

>>> /bye
<!-- gh-comment-id:2622832602 --> @rick-github commented on GitHub (Jan 29, 2025): `/save` saves context which is replayed as user messages when the saved model is reloaded. To remove it from the model, clear and save. Create a model with saved context: ```console $ ollama run test >>> hello Hello! How can I assist you today? >>> /save test Created new model 'test' >>> /bye ``` Load a model with saved context. The previously entered "hello" prompt is replayed: ```console $ ollama run test >>> hello Hello! How can I assist you today? >>> /bye ``` Load a model with saved context, clear it and save it: ```console $ ollama run test >>> hello Hello! How can I assist you today? >>> /clear Cleared session context >>> /save test Created new model 'test' >>> /bye ``` Load a model that had saved context that was cleared: ```console $ ollama run test >>> good morning Good morning! How can I assist you today? >>> /bye ```
Author
Owner

@iplayfast commented on GitHub (Jan 29, 2025):

Well that cleared my flappy bird. Maybe I did a /save without realizing it after the flappybird was created.
I'll close this, and if it shows again, I'll reopen it.
Thanks for looking into it for me.

<!-- gh-comment-id:2622848772 --> @iplayfast commented on GitHub (Jan 29, 2025): Well that cleared my flappy bird. Maybe I did a /save without realizing it after the flappybird was created. I'll close this, and if it shows again, I'll reopen it. Thanks for looking into it for me.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#5571